You can make a few lists which would contain certain letters, for example a list which contains letters that count as one point:
tab_onepoint = ['e','a','i','o','n','r','t','l','s','u']
A list which contains letters that count as two points:
tab_twopoint = ['d', 'g']
And so on, and so on.
And then you could iterate through the string and check if "i" is in the "onepoint" list, so if it is, +1 would be added to the score. So after iterating through the string "Hello" score would be equal to 4. You can then make the other lists, so it would iterate through them too and it would add to the score adequately.
Full code:
tab_onepoint = ['e','a','i','o','n','r','t','l','s','u']
string = "Hello"
score = 0
for i in string:
if i in tab_onepoint:
score += 1
elif i in tab_twopoint:
score+= 2
//edit:
Here is also a solution for a dictionary (as one person in comments suggested):
points = {**dict.fromkeys(['e', 'a', 'i', 'o', 'n', 'r', 't', 'l', 's', 'u'], 1), **dict.fromkeys(['d', 'g'], 2), **dict.fromkeys(['b', 'c', 'm', 'p'], 3), **dict.fromkeys(['f', 'h', 'v', 'w', 'y'], 4), 'k': 5, **dict.fromkeys(['j', 'x'], 8), **dict.fromkeys(['q', 'z'], 10)}
string = "Hello"
score = 0
converted_string = string.lower()
for i in converted_string:
if i in points:
score = score + points[i]
print(score)
What is "fromkeys" method doing, is basically creating dictionaries inside this one dictionary. So basically, every single letter of 'e', 'a', 'i', 'o', 'n', 'r', 't', 'l', 's', 'u' is becoming a key to the value of 1. The same goes for the rest of the keys and their values. Note that I'm converting the input string to lower letters, just so it will fit with the dictionary's keys.
You just have to pack this solution into a function, and here you go. I guess it would also be okay to make this dictionary global.
Also - you've made a mistake in your spelling. "Hello" gets us a score of 8, you wrote "Helo", which gets us a score of 7.