trouble with lists

anandr86 at gmail.com anandr86 at gmail.com
Tue May 3 13:42:43 EDT 2005


I'm new to python. I tried doing this

>>> x = [[]] * 3
>>> print x
[ [] [] [] ]
>>> x[0].append( 2 )
[ [2] [2] [2] ]

I confused with the last line output. I actually expected something
like

[ [2] [] [] ]

Can anyone give me an explanation. help!!




More information about the Python-list mailing list