Scrabble: It returns "None" when it should return "5"


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

It does what it is supposed to do, but throws this error, I do not quite understand why. Please help me to get this sorted out.

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):
    total = 0
    word = raw_input("Your word: ").lower()
    for scores in word:
        total += score[scores]
    print total


It doesn't ask you to use user input. Additionally, you need to return the total instead of printing. All you have to do is take out

that line,

use return instead of print,

and at .lower() on the end of word.

To call the function and print it, just try

print scrabble_score("string") with whatever word you want.


Thank you. All is fine now.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.