Answer to Question #39170 in Python for Afreen

Question #39170
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

print cycle_move(a)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS