[issue29584] 2D list with Bugs when defined by using Multiplication

Yaowei Zhang report at bugs.python.org
Thu Feb 16 21:03:45 EST 2017


New submission from Yaowei Zhang:

#If we define a list by:
nums = [[0]*3]*3
#nums = [[0,0,0],[0,0,0],[0,0,0]]
nums[0][1] = 1
print(mums)
# the result is
[[0,1,0],[0,1,0],[0,1,0]]
#I think it is because all the line use the same list variable, but it suppose #not.

----------
components: +Build -Library (Lib)
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29584>
_______________________________________


More information about the Python-bugs-list mailing list