1

Lets say I have the following class:

class test(object):
    def __init__(self):
        self.arr = [0]*10

And then I use it as:

arrOfTests = [test()]*10
arrOfTests[0].arr.insert(0,1)
print arrOfTests[0].arr[0]
print arrOfTests[1].arr[0]

Which returns

1
1

Why is arr[0] of attOfTests[1] (and also all the others) 1 as well? By all my best effort, I could not figure this out.. Thank you in advance!

stuckolai
  • 11
  • 1

0 Answers0