• Register
0 votes
1.4k views

Problem : 

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 ?

6 5 3
6,930 points

2 Answers

0 votes

Solution :

It Should be .index(i) - parenthesis, not brackets as shown below

e.g. 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)]='' 
     return rack_prov

Further Readings:

https://github.com/facebook/PathPicker/issues/242

9 7 4
38,600 points
0 votes

Solution:

I figure out you want

listb.pop()[0]

The expression listb.pop is a valid python expression which results in a reference to the pop method, however doesn't really call that method. You require to include the open and close parentheses to call the method.

You used [] instead of () at the time attempting to call append.

Seems like you typed brackets instead of parenthesis by mistake.

You are attempting to access pop as in case was a list or a tupple, however pop is not. It's a method.

instead of writing listb.pop[0] write

listb.pop()[0]
         ^
         |

This error arises at the time you don't use brackets with pop operation. Write the code in this manner.

listb.pop(0)

or You can attempt this code

featIndex = featLabels.index(firstStr)

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 9 views
9 views
On making a small program for math there returned an error "TypeError: 'NoneType' object is not subscriptable. Never before has been seen, this error, so no idea what it means. import math print("The format you should consider:") print str("value 1a")+str(" + ")+ ... /Nathan/Documents/Python/New thing", line 16, in <module> a = lista[1] - lista[0] TypeError: 'NoneType' object is not subscriptable
asked 1 day ago psandprop 1.4k points
1 vote
1 answer 241 views
241 views
Problem: When I run or compile this program import urllib2 import time import datetime HolaAndre = 'HUA','WALT','NOKA','CMG','EVAL','DARZ','SYM' def BackData(stock): try: print 'Still pulling',stock print str(datetime.datetime.fromtimestamp(time. ... BackData(eachStock) It shows me the following error main loop 'builtin_function_or_method' object is not iterable What is the problem please help me.
asked Apr 5 LizzyM 6.1k points
2 votes
1 answer 41 views
41 views
Problem: What is TypeError: 'list' object is not callable error in python programming? Why does it happen? I was trying to working with a list in python. Suddenly, I got this error while I was trying run this below code list = [1, 2, 3] myrange = list(range(1, 10)) for num in list: if num in myrange: print(num, 'is between 1 and 10') Could any of you please shed some light on this?
asked Apr 7 Gavin 15.3k points
1 vote
1 answer 500 views
500 views
Problem: I have a data frame to count my daily costs and when I try to input this to my cost using python script it always shows the error: TypeError: Object of type 'int64' is not JSON serializable The script I wrote is: ... update_list.append(update_data) all_data_cursor = all_datapull.costforce_login() all_data_cursor.bulk.Account.update(update_list) Can anyone help me out to fix this thing.
asked Apr 7 LizzyM 6.1k points
1 vote
1 answer 54 views
54 views
Problem: I am very noob in python programming language. To develope my skills I have been doing some coding prcatice. So, I wrote some which gives me error. The code I wrote is: for_test = "hiihihiiiiihhhi" print("The string you give is : " + str(for_test)) res = ... ')('%temp%', 'i') TypeError: 'str' object is not callable Why this error message is appearing can anyone explain.Please help me out.
asked Apr 7 LizzyM 6.1k points