converting letters to numbers

kjakupak at gmail.com kjakupak at gmail.com
Tue Oct 8 10:28:18 EDT 2013


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). 

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.



More information about the Python-list mailing list