def rotate( arr, n): a[0],a[1:]=a[-1],a[:n-1] #Driver Code a=[-1,2,3,7,5] rotate(a,len(a)) print(a) #Output: [5, -1, 2, 3, 7]