python 2.7 - How to move current element to next position -
intention infinitely cycle through list, this: l=[1,2,3,4,5]
after first loop l=[5,1,2,3,4]
after second loop l=[4,5,1,2,3]
and on,
without using double ended queue, itertool
use simple list
you can using this:
l = l[-1:] + l[0:-1]
so after first iteration [5, 1, 2, 3, 4], after second [4, 5, 1, 2, 3]
Comments
Post a Comment