How do I define a function?


I got this error: Oops, try again. Did you create a function called scrabble_score? Your code threw a "global name 'scrabble_score' is not defined" error.

I know my code is probably wrong on multiply levels but I specifically want to know why it's saying "global name 'scrabble_score' is not defined", I like to think I at least know how to define a function.

def scabble_score(word):
    for key in word:
        if word[key]==score[key]:
    return total


There is a spelling mistake in your functions name. You wrote "scabble" instead of "scrabble". This will solve the error. :slight_smile:


No comparison necessary. Also, it will never work since key is a letter, and score[key] is a number.

A much simpler approach...

for letter in word:
    total += score[letter]


Thanks to the both of you, I'm still such a butthead at this.


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