I don't understand why I get the following error message:

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

I don't even understand why it returns "1" and not "3"

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):
    word = word.lower()
    for i in word:
        result = 0
        result = result + score [i]
    return result

Can someone help me?

On the other hand, is it normal that I need to read the Q&A forum (or sent a message) for almost every step of the "Practice Makes Perfect" lesson ?


you declare a variable result, and give it a value of zero

But since you do this inside the loop, each iteration of the loop result gets assigned a value of zero, so adding to result won't persist

declare result outside the loop

Practice makes perfect pushes you to the next level, this can be a struggle. Take your time, write psuedo code, think about what you learned and what you might need to design your program

Try not to go to the forum to quickly


Thank you very much

Apparently, I should be more patient


if you want to get the maximum learning reward from the lessons, yes

Add a function call, add print statements inside your function so you can actually see what is happening


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