faqts : Computers : Programming : Languages : Python : Common Problems : Lists

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 17 people (76%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How to build arbitrarily-sized lists in one fell swoop?

Jul 27th, 2000 01:16
unknown unknown, Remco Gerlich


l = [x]*n
Does what you do here. I don't know what kind of object x is, but note
that this doesn't make *copies* of x; if it's some instance, then all
elements of l will be a reference to the same old x. Same for your
methods.