[Tutor] List of lists help

Mark Tolonen metolone+gmane at gmail.com
Thu Nov 20 16:54:40 CET 2008


"Alan Gauld" <alan.gauld at btinternet.com> wrote in message 
news:gg394h$k1f$1 at ger.gmane.org...

[snip]

> Something like
>
>>>> L = [[0,0,0] *3]

I think you meant:

>>> [[0,0,0]]*3
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]

-Mark

>
> Now L contains 3 copies of the same list so when you change
> any one copy it is reflected in all of the other copies.
>
>>>> L[0][1] = 6
>>>> L
> [[0,6,0],[0,6,0],[0,6,0]]




More information about the Tutor mailing list