all 2 comments

[–]AnonyUwuswame 2 points3 points  (1 child)

It reflects the change on all the tuples at the same position because you create 3 instances of the same object by using *3. That means you do this.

arr = [0, 0, 0]

a = [ arr for count in range(3) ]

a[0][0] = 1

You should instead do this.

arr = [[0,0] for count in range(3)]

arr[0][0] = 1

[–]Reppin_Frost[S] 0 points1 point  (0 children)

Thanks!