I have the next test task:
arr = [4,3,2,1]
arr[0], arr[arr[0]-1] = arr[arr[0]-1], arr[0]
print(arr)
I'd expect the result as [1,3,2,4] as we assign new values to elements of the list. But it gives the result as the initially [4,3,2,1].
Why does it work in this way? Why does it change not the list?
If to make it in the next way:
arr[0], arr[3] = 1 , 4
it works...