List - rotate
Dale Strickland-Clark
dale at riverhall.NOTHANKS.co.uk
Wed Jan 23 04:27:55 EST 2002
nikolai.kirsebom at siemens.no (Nikolai Kirsebom) wrote:
>Probably easy - but can't seem to find "the solution" to rotating
>content of a list (in one statement - competition with a lisp-guru !).
>
>For a string I do the following to Rotate Right:
>
>s = "abc"
>s[1:]+s[0]
>>> s = "bca"
>
>which works correctly.
>
>Tried the following for list, does not seem to work.
>a = [1,2,3]
>a[1:].append(a[0])
>
>Nikolai
How about this:
a.append(a.pop(0))
--
Dale Strickland-Clark
Riverhall Systems Ltd
More information about the Python-list
mailing list