+ 1
Information practice class 11
Write a program in python to shift elements of a list so that first element moves to the second index and second index moves to the third index,etc,and last element shifts to the first position Suppose list is [10,20,30,40] After shifting it should look like : [ 20,30,40,10] if anyone can solve this please help. Don't spam
3 odpowiedzi
+ 1
Thanks for the answer. That's what I have wondering too. In my text the question was given like this. So I don't really know whether it's right or not
0
list = [10,20,30,40]
list = [list[-1]] + list[:-1]
0
U said last element shifts to 1st position, itll be [40,10,20,30] not [20,30,40,10](1st to last)