converting letters to numbers

random832 at fastmail.us random832 at fastmail.us
Tue Oct 8 11:58:36 EDT 2013


On Tue, Oct 8, 2013, at 11:44, kjakupak at gmail.com wrote:
> def add(c1, c2):
>     ans = ''

This only makes sense if your answer is going to be multiple characters.

>     for i in c1 + c2:

This line concatenates the strings together.

>         ans += chr((((ord(i)-65))%26) + 65)

The way you are doing the modulus, this results in - well, let me
illustrate:

>>> add('','WXYZ[\]^_`abcde')
'WXYZABCDEFGHIJK'



More information about the Python-list mailing list