Basically there seems to be a problem when a list of lists is made by appending a list to another list using list.append(). The problem is that the entire column is changed to the value you set it to for the index you give. for example the code here
b = [1,1,1]
c = []
c.append(b)
c.append(b)
c.append(b)
c[0][0] = 4
and if you print c you would get:
[[4,1,1][4,1,1][4,1,1]]
instead of
[[4,1,1][1,1,1][1,1,1]]
So my question is how would you be able to end up with the list to the right rather than what actually happens.
What you’ve observed is normal and expected behavior in Python and any decent tutorial should cover it.
This appends to
cthree references to the listb. Since it’s the same list, changing one reference changes it in all four places it’s referenced, includingbby the way.If you don’t want this behavior, copy the list.