9 scrabble_score


#1

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):
total = 0
word = str(word).lower()
for n in word:
n = str(n)
total += score(n)
return total

can someone tell me what is wrong with my code and explain why?

"Does your scrabble_score function take exactly one argument (a string)? Your code threw a "'dict' object is not callable" error" is the error i am getting


#2

Remove the str() from word = str(word).lower(). That might work.


#3

i tried that and still have the same error :confused:


#4

Did you read your error message? Reread it and compare it to this part of your code.


#5

ahhhhhhh thanks i figured it out its because i used

total += score(n)

instead of

total += score[n]


#6

you need "total+=score[n]" (you neeed the square brackets)