2D lists
Mikael Olofsson
mikael at isy.liu.se
Tue Jan 21 07:57:00 EST 2003
On 21 Jan 2003 03:12:10 -0800
alan_salmoni at yahoo.com (Alan James Salmoni) wrote:
> a = [0] * 3
> b = []
> b.append(a)
> b.append(a)
Not so good:
>>> a = [0] * 3
>>> b = []
>>> b.append(a)
>>> b.append(a)
>>> b
[[0, 0, 0], [0, 0, 0]]
>>> b[0][0]=1
>>> b
[[1, 0, 0], [1, 0, 0]]
Oops!
> c = [[0]*3,[0]*3]
This one works.
/Mikael
-----------------------------------------------------------------------
E-Mail: mikael at isy.liu.se
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
/"\
\ / ASCII Ribbon Campaign
X Against HTML Mail
/ \
This message was sent by Sylpheed.
-----------------------------------------------------------------------
Linköpings kammarkör: www.kammarkoren.com
More information about the Python-list
mailing list