Python program to rotate list elements with next elements
Write a program rotates the elements of a list so that the elements at the first index moves to the second index , the element in the second index moves to the third index, etc., and the element at the last index moves to the first index.
lst=eval(input("Enter a list : ")) print("List before Rotation :",lst) a=lst s=len(lst) for i in range(1,s): lst[i-1]=lst[i] lst[s-1]=a print("List after Rotate :",lst)
Enter a list : [3,4,5,6]
List before Rotation : [3, 4, 5, 6]
List after Rotate : [4, 5, 6, 3]