Sequence of empty lists
Peter Hansen
peter at engcorp.com
Tue Feb 22 08:39:58 EST 2005
Diez B. Roggisch wrote:
> seq = [[] for i in xrange(10)]
And the reason you need that approach is given in the FAQ:
http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list
It's a very good idea to read the entire FAQ as soon as you've gotten
past the very basic Python level, so that you can save yourself
and others a lot of time stumbling over the traditional problems
that everyone goes through. You'll learn a lot of useful things
in the process.
-Peter
More information about the Python-list
mailing list