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

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -