I couldnt figure our why it comes out 24...
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
"x": 8, "z": 10}
def scrabble_score(word):
for x in word:
return total

Oops, try again. Your function fails on scrabble_score("pie"). It returns "24" when it should return "5".



If you use


the associated Value of the property "x" will be used,
which is the number Value 8

As the =indentation= is very important
Please re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use


I guess you are looping once. The idea is to compare each score[key] to each character in word, so if the character matches add the value of score[key] to total, at the end return total


even better
comparing each character in word to score[key]

def scrabble_score(word):
    word = word.lower()
    total = 0
    for item in word:
       if item in score:
    return total

This works for me, its almost indenticle to yours. except for one thing, see if you can notice it.


Just for the purpose of sharing, this is my code:

def scrabble_score(word):
    word_score = 0
    for char in word.lower():
        for key in char:
            word_score += score[key]
    return word_score
print scrabble_score("hello")