# left rotate using slicing
def leftRotate(arr, k, n):
arr = arr[k:] + arr[:k]
print(arr)
arr = [1, 2, 3, 4, 5, 6, 7]
leftRotate(arr, 2, 7)
print(arr)
Result:
[3, 4, 5, 6, 7, 1, 2]
[1, 2, 3, 4, 5, 6, 7]
When I print the array outside the function it is not rotated anymore and remains how it originally was. Can someone help me understand this?