9/15 Code does not work on last input


I dont understand why it has stuck at the last input.
“Your function fails on scrabble_score(“DuNe”). It returns “2” when it should return “5”.”

def scrabble_score(word):
my_list = []
total = 0

for letter in word:

for letter in my_list:
for point in score:
if letter == point:
total += score[point]

return total
print total


oh okay i solved it.
forgot to assign the word to word.lower()


The letter scores is a lookup list, which for our purposes contains all we need assuming valid word characters are passed to the function. We do not need to iterate the dictionary, only the word (which is iterable so no list required, either).

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


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