I'm very new to dictionaries and I'm trying to implement a simple game of scraable in python that returns the score I get for each word I input. However I`m not to familiar with dictionaries and I want to understand what's wrong with my code.
I've created a dictionary where every letter has its own score.
points = {'A':1, 'B':3, 'C':3, 'D':2, 'E':1, 'F':4, 'G':2,
'H':4, 'I':1, 'J':8, 'K':5, 'L':1, 'M':3, 'N':1,
'O':1, 'P':3, 'Q':10, 'R':1, 'S':1, 'T':1, 'U':1,
'V':4, 'W':4, 'X':8, 'Y':4, 'Z':10}
def scraable():
total_score=0
word=input('Digit a word\n')
for i in word:
total_score=total_score+points[i]
return total_score
print(scraable())
It gives me a key error 'p' and I don`t know what type of error is this
i.upper()in...+points[i]. Thanks @glhri.upper()noti.lower(), the keys are in uppercase.