python challenge question (string manipulation)

John Salerno johnjsal at
Wed Mar 29 21:34:03 CEST 2006

John Salerno wrote:

> It works, but is there a better way to shift the letters of the alphabet 
> for 'code'? I remember a method that did this for lists, I think, but I 
> can't remember what it was or if it worked for strings.

Ah ha! This is cleaner:

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?

More information about the Python-list mailing list