This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Liam
almost 10 years

Is it possible to get the value of a variable using an inputted string?

I would like to make a program that gives the value of a word based on all the letters added up with A being 1, B being 2 C being 3 etc. The code i am trying to use (and can’t) is:

A=1 B=2 C=3 Etc… Word = rawinput(‘text:’) Wordlen = len(word) Counter = 0 Finalword =0 While wordlen > counter Finalword =+ input (word[counter]) Counter =+ 1 print (finalword)

I’m only a beginner and am doing this for no reason but I can’t find an answer anywhere! When i run the program i get the first letter in the list every time and i sorta know why but I couldn’t find a better way to do it and nothing seems to work. And can someone explain why every time i type in ‘counter’ after typing in the word i get the next letter in the word?