Scrabble_score, 'unicode' object is not callable



I create this code, and thought it's good to use. But when I running code, shows out
Traceback (most recent call last):
File "python", line 19, in
File "python", line 14, in scrabble_score
TypeError: 'unicode' object is not callable

Hope somebody can help me out.

word = raw_input("Enter a word:")
print word
def scrabble_score(word):
    w = word.lower()
    s = 0
    i = 0
    while i < len(w):
        s += score[w(i)]
        i += 1    
    return s


Hi @datasolver52507 ,

In this line ...

s += score[w(i)]

... w is a string, so the syntax, w(i), appears to be an attempt to call a string as if it were a function.

Perhaps you actually intended to index w instead. What is the proper syntax for doing that?


That's the point. w is a string, I use it as a list.
Thank you for help.


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