On 21/03/2016 18:30, Maurice wrote:
Just figured why:
If I type this on the kernel:
weirdList = [[0]*3]*5
weirdList
Out[257]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
weirdList[0][0] = 1
weirdList
Out[259]: [[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]]
All first elements of the sublists also changes. I dunno why...
https://docs.python.org/3/faq/programming.html#why-did-changing-list-y-also-change-list-x
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list