9.Scrabble_score - 'returns "3" when it should return "5".'


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

What should be corrected? The error I get is

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

This is my code -->

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


a function ends the moment a return keyword is reached

so your function ends in the first iteration of the loop, to get the correct total, the whole loop needs to run


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