Search code examples
pythonpython-3.xpython-requestsnameerror

I'm trying to produce a line of code the returns the score of a word but at the moment I am getting an error


def getWordScore(word):
    points_total = 0 
for letter in word:
      points_total += getLetterScore.get(letter,0)
return points_total
brownie_points = getWordScore("BROWNIE")

output NameError: name 'word' is not defined

I'm a bit confused at why I'm getting the nameError,Any suggestions?


Solution

  • a proper indentation should do the trick

        def getWordScore(word):
            points_total = 0
            for letter in word:
                points_total += getLetterScore.get(letter, 0)
            return points_total
    brownie_points = getWordScore("BROWNIE")
    

    do notice that you have not provided getLetterScore, so there might be some other issues