List - rotate

Duncan Booth duncan at
Wed Jan 23 06:13:59 EST 2002

Dale Strickland-Clark <dale at> wrote in 
news:nf0t4ugt1qio7r34eg392st617h6qk9nc1 at

>>For a string I do the following to Rotate Right:
>>s = "abc"
>>>> s = "bca"
>>which works correctly.
>>Tried the following for list, does not seem to work.
>>a = [1,2,3]
To mutate a list you should use pop and append.
To create a new, rotated list you can use similar code to your string. The 
following should work for any sequence type including list, tuple and 
    	s = s[1:]+s[:1]

Duncan Booth                                             duncan at
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

More information about the Python-list mailing list