9/15 [solved]


#1



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


Error message says, that "pie" returns 17 instead 5. If I change "sum(total)" to just "total" it return the long list of "1" and one "3". I don't now what is wrong with this loop.


Could you please look at my code and say what Ishould change?


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}
your_word = []
total = []
word = raw_input("Your word:").lower()

def scrabble_score(word):
    for i in word:
        your_word.append(i)
    for x in your_word:
        if x in score:
            scr = score[x]
            total.append(scr)
    else:
        return sum(total)


#2

In order to validate your function works correctly, the exercise will call the function (not the whole script) multiply times

place your_word = [] and total = [] inside your function


#3

Thanks! It worked :slight_smile:


#4