converting letters to numbers

Mark Lawrence breamoreboy at yahoo.co.uk
Tue Oct 8 12:05:33 EDT 2013


On 08/10/2013 15:28, kjakupak at gmail.com wrote:
> I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter).
>

I'd say the requirement is lacking in that no encoding is specified.

> All I have so far is:
>
> def add(c1, c2):
>      ord(c1) - ord('a') + 1
>      ord(c2) - ord('a') + 1
>
> I know I need to use ord and chr, just not sure how.
>

I'll further observe from your later replies that you're suffering from 
the highly contagious, highly virulent double line spacing disease. 
This is known to cause severe eye strain leading to blindness.  In can 
be cured by purchasing medication here 
https://wiki.python.org/moin/GoogleGroupsPython

-- 
Roses are red,
Violets are blue,
Most poems rhyme,
But this one doesn't.

Mark Lawrence




More information about the Python-list mailing list