Lists & two dimensions

Gerhard Häring gerhard.haering at gmx.de
Sat Jul 20 09:59:10 EDT 2002


* Pichai Asokan <asokanp at virtusa.com> [2002-07-20 06:46 -0700]:
> I am a trainer and in a training session a participant came up with a
> problem that stumped me:
> --------------------
> board = [[-1] * 3 ]*3
> [...]

It's useful to search the FAQ. Actually, I found it very useful to take
the time once and read the _whole_ FAQ :-)

Your relevant entry is
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.050.htp

and it's called
"My multidimensional list (array) is broken! What gives?"

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))





More information about the Python-list mailing list