Simple list.append() question

Matthew Hirsch meh9 at cornell.edu
Mon Apr 24 11:19:24 EDT 2000


Hi All,

I have this:
>>> entire_list=[[]]*3
>>> entire_list
[[], [], []]
>>> entire_list[0].append(1.23)
>>> entire_list
[[1.23], [1.23], [1.23]]

I only want to append 1.23 to entire_list[0].  Why did it also append it 
to entire_list[1] and entire_list[2]?

Thanks for your help,
Matt



More information about the Python-list mailing list