Practise Makes Perfect: 9. scrabble_score


#1



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


#2

indent yourreturn statement same indenation level as for loop!


#3

: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...


#4

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


#5

Thanks sensei :pray: :wink:


#6

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


#7

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:


#8

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


#9

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