List problem

Alan Bromborsky abrombo at verizon.net
Sun Dec 16 18:02:11 EST 2007


I wish to create a list of empty lists and then put something in one of 
the empty lists.  Below is what I tried, but instead of appending 1 to 
a[2] it was appended to all the sub-lists in a.  What am I doing wrong?

 a = 6*[[]]
 >>> a
[[], [], [], [], [], []]
 >>> a[2].append(1)
 >>> a
[[1], [1], [1], [1], [1], [1]]
 >>>  



More information about the Python-list mailing list