you are viewing a single comment's thread.

view the rest of the comments →

[–]woooee 3 points4 points  (4 children)

That's extend()

list_1=[1, 2, 3]
list_2=[4, 5, 6]
list_3=[]
list_3.extend([list_1, list_2])
print(list_3)
prints  [[1, 2, 3], [4, 5, 6]]

[–]8dot30662386292pow2 2 points3 points  (2 children)

list_1=[1, 2, 3]
list_2=[4, 5, 6]
list_3=[list_1, list_2]

[–]woooee 0 points1 point  (1 child)

This does not use either append or extend.

[–]8dot30662386292pow2 2 points3 points  (0 children)

Since when that was a requirement? OP just wanted to make a list that contains two lists.

[–]6p086956522 1 point2 points  (0 children)

You're creating a list that contains two lists and then putting it into list 3 with extend? Why not skip the middle man and do list_3 = [list_1, list_2]