Programming Examples

Python program to rotates the elements of list so that fist elements move to second and second to the third


python program to rotates the elements of list so that fist elements move to second and second to the third

Write a python program to 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 elements in the last index moves to the first index.

mylist=eval(input("Enter any List of Integer : "))
temp=mylist[len(mylist)-1]
for a in range(len(mylist)-1,0,-1):
    mylist[a]=mylist[a-1]
mylist[0]=temp
print("After Shift List is : ",mylist)
Output

Enter any List of Integer : [3,5,8,9,6]

After Shift List is :  [6, 3, 5, 8, 9]

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz