List - rotate

Nikolai Kirsebom nikolai.kirsebom at siemens.no
Wed Jan 23 10:02:53 CET 2002


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




More information about the Python-list mailing list