List behaviour

Gabriel gabe at dragffy.com
Thu May 15 06:52:10 EDT 2008


Diez B. Roggisch <deets <at> nospam.web.de> writes:

> So instead of creating a list of list by the *-operator that only multiplies
> the references (which is fine immutable objects like strings or numbers),
> you need to explicitly create new lists, e.g. with a list-comprehension:
> 
> tasks = [[] for _ in xrange(6)]
> 
> Try this and everything will work as expected.
> 

Thanks, Diez.

Thanks to all who replied to help me with this :)




More information about the Python-list mailing list