• Register
0 votes
1.7k 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

Please log in or register to answer this question.

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 17 views
17 views
Problem: Hi there! I am a beginner and do not have much experience in programming. I am trying to run the following program: entries = int(input("Enter the number of items you want to add in the list: ")) lis = [] for i in range(1, entries+1): lis.append ... not know what I am doing wrong. This program was working correctly till yesterday, but I do not know what is wrong with it now. Please help.
asked Jan 16 Code Learner 5.5k points
0 votes
1 answer 17 views
17 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 Oct 24, 2020 psandprop 2.4k points
1 vote
1 answer 359 views
359 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, 2020 LizzyM 6.1k points
0 votes
1 answer 5 views
5 views
Problem: I&rsquo;m working on the count problem, and have come up with the following code: def count(sequence, item): found = 0 for i in len(sequence): if sequence[i] == item: found = found + 1 return found
asked 1 day ago Mashhoodch 6.1k points
2 votes
1 answer 57 views
57 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, 2020 Gavin 15.3k points
1 vote
1 answer 762 views
762 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, 2020 LizzyM 6.1k points
1 vote
1 answer 63 views
63 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, 2020 LizzyM 6.1k points
1 vote
1 answer 44 views
44 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, 2020 LizzyM 6.1k points
1 vote
1 answer 100 views
100 views
Problem: I am doing a course on python programming language. As a begginer I have to do a lot of programming practice and some of them are very confusing. Today I wrote a code to do some counting problems in python. The code I wrote is: def count(serial, totals): ... is not iterable What is the problem in my programm and what should I do now. Can anyone explain me this error. Thanks in advance.
asked Apr 4, 2020 LizzyM 6.1k points
1 vote
2 answers 239 views
239 views
Problem: I am begginer in python programming language and I am doing a course in it. I was doing some code to practice python programing. I wrote this code while doing my practice from __future__ import division x = 6.86 y = 9.79 z = 3.03 round((x/y)*0.88*z) But it ... is not callable Is there any problem in my code. I am using python 2.7 as my default python version . I am new so please help me.
asked Apr 4, 2020 LizzyM 6.1k points