Unexpected behavior of list of list

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 9 20:50:09 EST 2007


En Fri, 09 Mar 2007 22:30:09 -0300, kghose <kaushik.ghose at gmail.com>  
escribió:

> The following code
>
> listoflists = [[]]*2
> listoflists[0].append(1)
>
> appends(1) to both listoflists[0] and listoflists[1] (which I did not
> expect)

See latest posts on this list, or read the FAQ.

-- 
Gabriel Genellina




More information about the Python-list mailing list