1
    >>> ar = [[0,0,0], [0,0,0], [0,0,0]]
    >>> ar
    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    >>> ar[0][0] = 1
    >>> ar
    [[1, 0, 0], [0, 0, 0], [0, 0, 0]]

what is different about this?

    >>> a = [[0]*3]*3
    >>> a
    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    >>> a[0][0] = 1
    >>> a
    [[1, 0, 0], [1, 0, 0], [1, 0, 0]]

I think the first thing is right. What is different?

I thought I knew Python very well, but I got stuck...

ParthS007
  • 2,581
  • 1
  • 22
  • 37
김양우
  • 29
  • 4

0 Answers0