Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
1
Indexable
Never
char_list = ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!']


result_string = ''.join(char_list)


print("Resulting string:", result_string)




def square_list(lst):
    squared_list = [x**2 for x in lst]
    return squared_list

# Example usage
input_list = [1, 2, 3, 4, 5]
result = square_list(input_list)
print(result)
   





def add_lists(list1, list2):

    result = []

  
    min_length = min(len(list1), len(list2))

    
    for i in range(min_length):
        result.append(list1[i] + list2[i])
    if len(list1) > min_length:
        result.extend(list1[min_length:])
    elif len(list2) > min_length:
        result.extend(list2[min_length:])

    return result

list1 = ["M", "na", "i", "Ke"]
list2 = ["y", "me", "s", "lly"]


result_list = add_lists(list1, list2)

print("Resulting list:", result_list)







def square_list(lst):
    squared_list = [x**2 for x in lst]
    return squared_list


input_list = [1, 2, 3, 4, 5]
result = square_list(input_list)
print(result)

Leave a Comment