9. scrabble_score. "threw a "'test'" error"


I'm getting the error "Your code looks a bit off--it threw a "'test'" error. Check the Hint if you need help!"
it seems to be to do with the first line of my code where i declare the function but i dont see what's wrong with it. This is the third time i've written this out in different ways and i'm getting the same error.

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) :
    c = 0
    t = 0
    l = len(word)
    word = word.lower()
    while c <= l :
        t = t + score[word]
        c += 1
    return t




t = t + score[word]

you try to access the scores stored in the score dictionary, but the keys in the dictionary are individual letters, not whole words. You need to loop over word, since you need the letters of the word to get the score


oh of course, thankyou very much


That should help you, see if you can solve it now, if you however stay stuck you can post an updated version of your code, and i can help further but it would be better to try and solve it yourself


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