Aug-27-2017, 08:38 PM
It's a property of lists in python, which are mutable. When you do
When building lists like that, either do it explicitly, or do it with a list comprehension:
col=[[0,0]]*3
, you are not creating a list of three two item lists, you are creating a list of three pointers to one two item list. Since they are all pointing to the same thing, when you change it, all three of them report the change back.When building lists like that, either do it explicitly, or do it with a list comprehension:
col = [[0, 0] for row in range(3)]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures