Need some help...
bborcic at gmail.com
Tue Oct 30 12:43:09 CET 2007
hyozan.ux3 at gmail.com wrote:
> I want to create a program that I type in a word.
> for example...
> each letter equals a number....
> and so on.
> So Chaos would be
> C=13 H=4 A=1 O=7 S=5
> I want to then have those numbers
> 13+4+1+7+5 added together to be 30.
> How can I do that?
> Also, just curious, but, how could I then have the 3 and 0 added
> together to be 3?
> Please help me out.
> Thank you.....
>>> sum(dict(C=13,H=4,A=1,O=7,S=5)[_] for _ in 'CHAOS')
>>> sum(eval(ch) for ch in str(_))
More information about the Python-list