Concatenating Lists in Python
To combine lists, you can use the operator +
. This will give you a new list:
lst1 = [1, 2, 3]
lst2 = [4, 5, 6]
res = lst1 + lst2
print(res) # [1, 2, 3, 4, 5, 6]
The lists are given:
lst1 = ['4', '5', '6']
lst2 = ['1', '2', '3']
Write the code to get the following result:
['1', '2', '3', '4', '5', '6']
The lists are given:
lst1 = ['a', 'b', 'c']
lst2 = ['d', 'e']
lst3 = [1, 2, 3]
Combine them into a new list.