Michael wrote:
> Hi,
> I've got a string s, and i want to shift all the letters up by one, eg
> a->b, b->c ........ z->a
> In c++ i can do this quite simply with
>
> if(C == 'z') C='a';
> else C++;
>
> but i can't work out how to do this this in python??
>>> import string
>>> upone = string.maketrans(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA')
>>> string.translate("I've got a string s....", upone)
"J'wf hpu b tusjoh t...."
>>>
Note the difference though: the Python code does what you said you wanted,
whereas your sample code corrupts punctuation.
--
http://mail.python.org/mailman/listinfo/python-list