9. Scrabble score(This is the only one?!)


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/3?curriculum_id=4f89dab3d788890003000096#

Error:
Oops, try again. Remember to make your function work for upper- and lowercase letters!


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


#2

this:

ltr.lower()

won't work, it is making ltr lower, but this isn't stored anywhere. you really need to update the ltr variable, use a single equal sign to assign a new value to a variable.


#4

Thanks. I tried:

ltr = ltr.lower()

#5

that should do the trick. I assume you passed it?


#7

The above fix should do the trick! Another way I found to complete this problem is to make the whole input lowercase in the beginning, so the loop doesn't have to modify it each time:

def scrabble_score(word):
    word = word.lower()
    total = 0
    for i in word:
        total += score[i]
    return total

#8

you can even shorten that by doing lower at the start of the loop:

for i in word.lower():

this will convert the word into lower, and then loop over it


#9

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