[Tutor] List indexing problem
Michiel Overtoom
motoom at xs4all.nl
Sat Jul 26 02:20:09 CEST 2008
Mike wrote...
>Do you happen to know if there is an efficient way to initialize a list
>like this without explicitly writing out each element?
>>> temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
>>> print temp
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> print [[0]*3]*3
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
--
"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Vallopillil
http://www.catb.org/~esr/halloween/halloween4.html
More information about the Tutor
mailing list