On Fri, May 23, 2008 at 5:22 PM, Yuanxin Xi <[EMAIL PROTECTED]> wrote:
> I'm a Python newbie and still exploring, just surprised to see this 2D list
> assignment while debugging.
http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list
Kent
__
"Yuanxin Xi" <[EMAIL PROTECTED]> wrote
I'm a Python newbie and still exploring, just surprised to see this
2D list assignment while debugging.
>>> a = [[0] *3] *4
This creates a list with 3 zeros then creates a second list
with 4 references to the first list.
Remember that in Python all var
I'm a Python newbie and still exploring, just surprised to see this 2D
list assignment while debugging.
>>> a = [[0] *3] *4
>>> a
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> a[1][2] = 1
>>> a
[[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]]
why is that a[0][2] a[1][2] a[2][2] a[3][2] are all a