[Tutor] Nested list item assignment

Tore Ericsson tore.ericsson@telia.com
Thu, 26 Aug 1999 01:04:40 +0200


Can anybody explain line 6 in this:

>>> A = [[0]*3]*3
>>> A
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> A[0][0] = 1
>>> A
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]
>>> # One assigned, three updated!? 
>>>

Thanks / Tore