I have a list of lists, with identical elements, created like this:
list1=[1,2,3]
list2=[]
for i in range(6):
list2.append(list1)
list2
The outcome is:
[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]
I want to be able to change the elements of the nested list; for example:
list2[0][0]=4
list2
produces:
[[4, 2, 3], [4, 2, 3], [4, 2, 3], [4, 2, 3], [4, 2, 3], [4, 2, 3]]
But I only want to change the first element of the first list:
[[4, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]
How can I do this ? What am I missing in the iterating process ?
At the end, I want to be able to reference any element in list1