converting letters to numbers

kjakupak at gmail.com kjakupak at gmail.com
Tue Oct 8 11:44:47 EDT 2013


On Tuesday, October 8, 2013 11:36:51 AM UTC-4, rand... at fastmail.us wrote:
> 
> 
> 
> Your description says capital letters, but 'a' is a lowercase letter.
> 
> 
> 
> Does "mod 26" means A is 1, or is it 0? i.e., is A+A = B or is it A?
> 
> 
> 
> What should your function do if the letter isn't a capital letter from
> 
> the basic set of 26 English letters?

A is 0. 

Transfer it to an uppercase letter if it's a letter, if it's not then an error.
This isn't right, I know, just testing around

def add(c1, c2):
    ans = ''
    for i in c1 + c2:
        ans += chr((((ord(i)-65))%26) + 65)
    return ans



More information about the Python-list mailing list