newbie list handling question

Diez B. Roggisch nospam-deets at web.de
Tue Jan 13 10:49:02 EST 2004


> a = [[1, 10], [2, 20], [3, 30]]
> av = []
> 
> for i in a:
>   av.append(i)
> #av = a[:]

here you don't store a _copy_ of the contained list, but a reference
instead. Change av.append(i) to av.append(list(i)), and you should get a
copy of the list.


Diez



More information about the Python-list mailing list