"global name 'scrabble_score' is not defined"


#1



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

The error message to received is: Oops, try again. Did you create a function called scrabble_score? Your code threw a "global name 'scrabble_score' is not defined" error.


I am not sure why I am getting this error...


score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, 
         "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, 
         "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, 
         "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, 
         "x": 8, "z": 10}

    
def scrabble_score(word):
    word_lower = word.lower()
    letters_in_word = list.word_lower()
    total = 0
    for char in letters_in_word 
        total += score[char]
    return total


#2

1.You don't need this line.

letters_in_word = list.word_lower() (Its buggy too)

2.You can just loop over word_lower as its lowercased now.

3.You also need to end your for loop header with colon.

Make sure your code is indented properly.


#3

OH! Thank you! It works now!


#4

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