Re: [Tutor] Problem with assigning list elements
[EMAIL PROTECTED] wrote: I'm having a problem assigning numbers to a 2-D list. for the 2d list z for example, when I type in z[0][0]=67 every zeroth element of every sublist will be set to 67, instead of just element [0,0] being set to 67. http://effbot.org/pyfaq/how-do-i-create-a-multidimensional-list.htm Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem with assigning list elements
[EMAIL PROTECTED] wrote: I'm having a problem assigning numbers to a 2-D list. for the 2d list z for example, when I type in z[0][0]=67 every zeroth element of every sublist will be set to 67, instead of just element [0,0] being set to 67. If z = [[1,2],[3,4]] then z[0][0]=100 results in z= [[100,2],[100,4]] When I run that I see: z = [[1,2],[3,4]] z[0][0]=100 z [[100, 2], [3, 4]] Which is what I'd expect. Is this normal for python? And is there a way to assign to a specific element of a 2-dimensional list? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Problem with assigning list elements
I'm having a problem assigning numbers to a 2-D list. for the 2d list z for example, when I type in z[0][0]=67 every zeroth element of every sublist will be set to 67, instead of just element [0,0] being set to 67. If z = [[1,2],[3,4]] then z[0][0]=100 results in z= [[100,2],[100,4]] Is this normal for python? And is there a way to assign to a specific element of a 2-dimensional list? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem with assigning list elements
That is not the expected behavior and not the behavior I see: Python 2.5.1 (r251:54863, May 1 2007, 13:27:01) [C] on sunos5 z = [[1,2],[3,4]] z[0][0]=100 print z [[100, 2], [3, 4]] [EMAIL PROTECTED] wrote: I'm having a problem assigning numbers to a 2-D list. for the 2d list z for example, when I type in z[0][0]=67 every zeroth element of every sublist will be set to 67, instead of just element [0,0] being set to 67. If z = [[1,2],[3,4]] then z[0][0]=100 results in z= [[100,2],[100,4]] Is this normal for python? And is there a way to assign to a specific element of a 2-dimensional list? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor