Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 : TypeError: 'builtin_function_or_method' object is not subscriptable

I'm trying to make Scrabble in Python. The rack (where the 7 letters are) is a list where I appended 7 times tk.StringVar() Every time the player want to drop a word, I have to get the letters off the rack. Here's my problem. As I can associate the letters of the word dropped and the letters of the rack, I created a provisional list where I append each StringVar.get() from the initial rack. Then I created a code that change the dropped letters by an empty string '' as I can associate the initial rack with the provisional list. Here's my code

def defausse_rack_prov(word,rack_prov):
    word=word.get()
    for i in word:
        if i.upper() in rack_prov:
            rack_prov[rack_prov.index[i]]='' #This is the problematic line
    return rack_prov

I keep getting

TypeError: 'builtin_function_or_method' object is not subscriptable

What should I do ? Thank you :)

like image 704
Malik Fassi Avatar asked Mar 19 '26 21:03

Malik Fassi


1 Answers

Should be .index(i) - parens, not brackets.

like image 119
Amber Avatar answered Mar 21 '26 09:03

Amber