[Tutor] 2D list assignment

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Mar 12 20:22:03 EST 2004


> a=((2,4),(4,2))

THese are tuples. You aren't allowed to change tuples, they are whats
called immutable.

You can create lists from them and change those, or just start with
lists in the first place:

a = [[2,4],[4,2]]
a[1][1] = 4

Should now work.

HTH

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list