I'm eager to know is there any way to join tow or more lists into one?
Please help me with this.
li= ["v1", "v2", "v3"]
l2= [1,2,3]
print(joined_list)
You can append two or more lists into one list by using the methods below.
li1= ["v1","v2","v3"]
li2= [1,2,3]
joined_list= li1+li2
print(joined_list)
output:
['v1', 'v2', 'v3', 1, 2, 3]
joined_list= []
li1= ["v1","v2","v3"]
li2= [1,2,3]
joined_list.append(li1)
joined_list.append(li2)
print(joined_list)
Output:
[['v1', 'v2', 'v3'], [1, 2, 3]]
The parameters should be only iterables.
Example:
joined_list= []
li1= ["v1","v2","v3"]
li2= [1,2,3]
joined_list.extend(li1)
joined_list.extend(li2)
print(joined_list)
Output:
['v1', 'v2', 'v3', 1, 2, 3]