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

Popular posts from this blog

java - Checkbox item adds to spinner -

C# MVC AngularJS -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -