There are several other questions with nearly the same title, please read the full question.
I'm trying to shift a list in python to the right, and then modifying array[0]
, however doing this results in modifying both array[0]
and array[1]
:
arr = [[91, 3], [90, 3], [89, 3], [88, 3], [87, 3]]
pairs = enumerate
def shiftArray(a):
o = a[0]
for i in range(len(a)-1, -1, -1):
a[i] = a[i-1]
a[0] = o
return a
shiftArray(arr)
arr[0][0] += 1
print(arr) # [[92, 3], [92, 3], [90, 3], [89, 3], [88, 3]]