• Register
0 votes
2k 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 6 views
6 views
Problem: How I can fix this : builtin_function_or_method' object is not subscriptable python
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 58 views
58 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 9.2k points
0 votes
1 answer 45 views
45 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 498 views
498 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 9 views
9 views
Problem: how to I Solve this: int object is not subscriptable python 3 HELP! I need help understanding this: int object is not subscriptable python 3 Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 8 Mashhoodch 13k points
0 votes
1 answer 13 views
13 views
Problem: Hello all, I am encountering an error with my python script, and need help: Typeerror: 'map' object is not subscriptable.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 69 views
69 views
Problem: I am following instructions for a class homework assignment and I am supposed to look up the top 200 most frequently used words in a text file. Here's the last part of the code: fdist1 = FreqDist(NSmyText) vocab=fdist1.keys() vocab[:200] But when I ... 1, in <module> TypeError: 'dict_keys' object is not subscriptable Any suggestions on how to fix this so it can correctly return an answer?
asked Feb 21 Mashhoodch 13k points
0 votes
1 answer 212 views
212 views
Problem: when I make a function call to this method create({'1','2'}) I get an TypeError: 'set' object is not subscriptable error on line 'AWS': list(map(lambda id: f"arn:aws:iam::{id}:root", ids[i:i + 200])). Coming from a java background, is this somehow related to typecasting? Does the error mean that I'm passing a set data structure to a list function? How could can this be resovled?
asked Feb 19 Mashhoodch 13k points
0 votes
1 answer 28 views
28 views
Problem: I'm making a small program for math (no particular reason, just kind of wanted to) and I ran into the error "TypeError: 'NoneType' object is not subscriptable. I have never before seen this error, so I have no idea what it means.
asked Feb 4 Mashhoodch 13k points
0 votes
1 answer 30 views
30 views
I got stuck with this error. can anyone help thanks in advance
asked Jan 22 Lalit Kumar 1.2k points