List Question

Donovan Hide donovan at sherbet.co.uk
Fri Jul 20 13:16:33 EDT 2001


Given:

a=[[0]*6]*6
a[3][3]=4
print a

[[0, 0, 0, 4, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 4, 0,
0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 4, 0, 0]]

What syntax should I use to get this result:

[[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0,
0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]

Thanks for the help,
Donovan Hide.





More information about the Python-list mailing list