• Register
Log In
0 votes

Problem : 

Here's my code

def defausse_rack_prov(word,rack_prov):
    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.9k 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):
     for i in word:
        if i.upper() in rack_prov:
     return rack_prov

Further Readings:


36.1k points
edited by
0 votes


I figure out you want


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


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


or You can attempt this code

featIndex = featLabels.index(firstStr)


12.8k points
edited by

Related questions

1 vote
1 answer 119 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 5.7k points
2 votes
1 answer 23 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.2k points
1 vote
1 answer 196 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 5.7k points
1 vote
1 answer 35 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 5.7k points
1 vote
1 answer 20 views
Problem: I have a python project located at C:\Users\ASUS\Documents\OPO\aoi.py But when I try to run this project: C:\Users\ASUS\Documents\OPO\aoi.py, line 55, in __init__ self.serv = socket(AF_INET,SOCK_STREAM) TypeError: 'module' object is not callable Why am I getting this type of error message. Can anyone explain me this thing.
asked Apr 4 LizzyM 5.7k points