When I assign to an element in 3d python list, it will change 3 element.
Does anyone know what happened?
When I assign to an element in 3d python list, it will change 3 element.
Does anyone know what happened?
Yep, It has to do with the underlying way in which arrays are stored in Python. When you created your array initially, with the [[0,0]]*4, you created four pointers to the same list(you did that four separate times, hence why 1/4 of your lists were changed). Thus, when you change 1 value, it changes it in that one list, but there are multiple pointers to the same list, so it appears to change multiple values. I highly recommend http://pythontutor.com/ for visualizing how your code is executed/the underlying structures at play.