converting letters to numbers

Joel Goldstick joel.goldstick at gmail.com
Tue Oct 8 11:01:12 EDT 2013


You wrote this:

def add(c1, c2):
    ord(c1) - ord('a') + 1
    ord(c2) - ord('a') + 1

First of all, this looks like homework.  People will help you with
concepts here, but most frown on just providing answers.  With that in
mind look at this:

>>> ord('A')
65
>>> ord('a')
97
>>>

In your assignment you refer to Upper case letters.  In your code you
take the ordinal value of lower case 'a'


-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list