Em Qua, 2006-03-29 às 19:34 +0000, John Salerno escreveu: > alphabet = string.ascii_lowercase > code = string.ascii_lowercase[2:] + string.ascii_lowercase[:2] > > Yet it still seems kind of verbose. But since that's the official > solution, I guess there's no other way to shift the characters in a string?
----------- from collections import deque from string import ascii_lowercase a = deque(ascii_lowercase) a.rotate(-2) print list(a) # prints ['c', 'd', ..., 'z', 'a', 'b'] ----------- But mind the performance! (as an exercise, time the performance of mine and your approach using the timeit module and post back to the list) HTH, -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list