[Solved] Join 2 elements of a list [closed]


To combine two items of two lists as string you need to iterate through both lists at the same time and concatenate the two items as strings.

list1 = [1, 2, 3, 4]
list2 = ['a', 'b', 'c', 'd']
list3 = [str(x) + str(y) for x, y in zip(list1, list2)]
print(list3)

the output will be:

['1a', '2b', '3c', '4d']

solved Join 2 elements of a list [closed]