0

Program to convert A to Z to numbers and add them

example if u have 'egg'= 5+7+7

24th Oct 2017, 9:34 PM
Anne Joseph
Anne Joseph - avatar
8 odpowiedzi
+ 1
tnks so much Eligijus Silkartas..... it worked
24th Oct 2017, 10:07 PM
Anne Joseph
Anne Joseph - avatar
0
Maybe this works. ord function returns ascii value of character. For example ord('a') = 97, ord('b') = 98. So I substract 96 from them and get desired numbers https://code.sololearn.com/cDJFDGAwIKye/?ref=app
24th Oct 2017, 9:52 PM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
ok tnks
24th Oct 2017, 10:02 PM
Anne Joseph
Anne Joseph - avatar
0
you are welcome 😊
24th Oct 2017, 10:08 PM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
how do I now make it to be variable that is any word i put wud bring it's sum
24th Oct 2017, 10:17 PM
Anne Joseph
Anne Joseph - avatar
0
you can define a function :D i've changed the code a bit. Now it takes user input, stores it to variable and prints it's character sum https://code.sololearn.com/cDJFDGAwIKye/?ref=app
24th Oct 2017, 10:23 PM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
Tnks dear.... Hv a lovely night
24th Oct 2017, 10:32 PM
Anne Joseph
Anne Joseph - avatar
0
thanks, u too
24th Oct 2017, 10:34 PM
Eligijus Silkartas
Eligijus Silkartas - avatar