case 1:
a=[1,2,3,4,5]
index k=2
a[:k],a[k:]=a[k:],a[:k]
When I swap array elements like this. I got this output.
**OUTPUT:[3, 4, 1, 2]
case 2:
b=[1,2,3,4,5]
b[k:],b[:k]=b[:k],b[k:]
but when I swap array elements like this i got this.The only difference is the order of swapping.
OUTPUT:[3, 4, 5, 1, 2]
If we swap two variables, the order of swapping doesn't make a difference.
i.e a,b=b,a
is same as b,a=a,b
.
Why this is not working in the case of lists/array?