Q. Write a program rotates the elements of a list show that the element at the first index moves to the second index, the element i n second index moves to the third index, etc, and the element in the last index moves to the first index.
You can understand by Watching video :-
Answer :-
lst = eval(input("enter the list = ")) print ("New list =", [lst[ -1] ] + lst[0 : -1] )
Output :-
Enter the list :- [3, 5, 6, 9, 10, 12, 15, 18, 20, 21]
New list = [21, 3, 5, 6, 9, 10, 12, 15, 18, 20]
>>>
Enter the list :- ["Path","Walla","Portal","Express"]
New list = ['Express', 'Path', 'Walla', 'Portal']
>>>
Enter the list :- ["C++","Python","Java","CSS"]
New list = ['CSS', 'C++', 'Python', 'Java']
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )