I wanna use nested lists as an array, but here's the problem:
[color=blue][color=green][color=darkred]
>>> a = [[0]*3]*3
>>> a[/color][/color][/color]
[[0, 0, 0], [0, 0, 0], [0, 0, 0]][color=blue][color=green][color=darkred]
>>> a[0][0] = 1
>>> a[/color][/color][/color]
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]
Could anybody please explain to me why three values were change? I'm
bewildered. Thanks!
[color=blue][color=green][color=darkred]
>>> a = [[0]*3]*3
>>> a[/color][/color][/color]
[[0, 0, 0], [0, 0, 0], [0, 0, 0]][color=blue][color=green][color=darkred]
>>> a[0][0] = 1
>>> a[/color][/color][/color]
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]
Could anybody please explain to me why three values were change? I'm
bewildered. Thanks!
Comment