I want to continuous get new data to a list, then append it to a superset list. My code is like the following
llist = []
ele = [0, 0]
ele[0] = 1
ele[1] = 2
llist.append(ele)
ele[0] = 3
ele[1] = 4
llist.append(ele)
ele[0] = 5
ele[1] = 6
llist.append(ele)
print(llist)
My target is to getting [[1,2], [3,4], [5,6]]. However, when the list is updated, the previous appended element changes too. So I am getting [[5,6], [5,6], [5,6]] instead. Is there a way to remove the impact of such post change?
At the beginning I was posting another code snippet which is not reproducing the problem, sorry for that
llist = []
list = [1, 2]
llist.append(list)
list = [3, 4]
llist.append(list)
list = [5, 6]
llist.append(list)