[Solved] Arrays being re-assigned (Python) [closed]


You are probably doing something like this:

a = [1 2 3 4 5]
b = a

a and b are really arrays, rather they are references to arrays. b=a means they both reference the same array.

You will need to copy the array instead of just copying the reference, like this:

b = a[:]

1

solved Arrays being re-assigned (Python) [closed]