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

what's wrong with my code ?

def scrabble_score(word):
    for y in word:
        return total


Unindent your return statement so that it lines up with your for loop.


so obvious mistake I barely check it out. thanks a lot !


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

I wrote this and it didn't work. After seeing this i realize that I needed brackets around the i. I was wondering what the [i] does that the (i) doesn't do. I thought it was a string, and not a list. Forgive me its a nudie question. I have only been studying this for a week or so.



That's totally okay and it's not

as you put it. Better to know now than never figuring it out. If you remember, this:


Is the way we access a specific element from a dictionary. So what you code is supposed to do is take the score of the specific letter and add it to the total through your for loop. It's important to do that in brackets becuase it means something else entirely in parentheses.


Thank you for clearing that up for me.


Welcome, if you forgot how to access using key I suggest reviewing previous topics again. :slight_smile:


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