Practise Makes Perfect: 9. scrabble_score


Practise Makes Perfect: 9. scrabble_score

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

It seems like it's only returning the value of the first letter...

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):
    res = 0
    for letter in word.lower(): 
        res += score.get(letter)
        return res


indent yourreturn statement same indenation level as for loop!


:tired_face: I don't know how many times I'm going to make that mistake. Thank you..!

That time I was really sure I'd done everything perfect too...


You sure will do!!
keep practicing !! :thumbsup:
keep up the good work!!


Thanks sensei :pray: :wink:


Im learning too! :thumbsup:
we're in same boat! :slight_smile:


That's true, I'm just glad there are people in the world who take a second to look back and help the more novice rowers in the coding boat. Much respect :slight_smile:


I have my code practically identical and get "Your function crashed on pie as input because your function throws a "'int' object is not callable" error."

I ran the code via text editor and python and still don't understand what is wrong


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