Hi i am working on Codecademy exercise 9/15. The goal is to create a scrabble function that takes a string as input then returns a score for that word.
They give you a dictionary to start off with and this is what I have so far after searching for "how to loop through a dictionary and add values" on google.
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}
1) total = 0 # takes your input word value and saves it to total
2) def scrabble_score(x): # defining function name
3) for i in score.values(): # loops through score
4) total += i # sums up your input key value
5) return i
this code keeps throwing a local variable total error.
does this mean that the total variable does not work with the scrabble_score(x) function?