[newbie/2.5.1.1] Computing value of a word?

Gilles Ganault nospam at nospam.com
Thu Feb 17 06:20:48 EST 2011


On Wed, 16 Feb 2011 01:27:06 -0800, Chris Rebert <clp2 at rebertia.com>
wrote:
>A = ord('a') - 1
>for line in your_file:
>    word = line.strip().lower()
>    score = sum(ord(letter)-A for letter in word)

Thanks much Chris.



More information about the Python-list mailing list