I am trying to create an empty list in python, but for some reason there is a difference in the two methods

Viewed 20

What is the difference between these two methods in python? Shouldn't the outcome for list2 be exactly the same?

Method 1:

list2= [[[], [], []], [[], [], []], [[], [], []], [[], [], []], [[], [], []]]

Method 2:

list1 = [[], [], []]
list2 = []
for i in range(5):
    list2_task.append(list1)
0 Answers
Related