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


#1



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


#2

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


#3

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