Write a python program that rotates the elements of a list so that the element at the first index moves to the second index,the element in the second index moves to the third index,etc,and the element in the last index moves to the first index.
1
Expert's answer
2014-03-04T10:30:11-0500
a = [1,2,3,4,5,6,7,8,9,0]
def cycle_move(l): l_new = [l[-1]] for i in l[:-1]: l_new.append(i) return l_new
Comments
Leave a comment