Scrabble_score


#1


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

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


Hi my code doesn't work but I can't figure it out.


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


#2

you have for else, this means else will run when the loop condition becomes false

You should have an if else instead, so that every time total gets increased when i is present in score


#3

Thx!
It works now!
Seems I need to read the for else instruction..


#4