ERROR: 'builtin_function_or_method' object is not subscriptable

Viewed 20
print("BOT: My name is Stark. Let's have a conversation! Also, if you want to exit any time, just type Bye!")

This is just a simple code having a bunch of if-else statements, in which I am taking input from a user and trying to give some logical response to queries.

while(flag==True):
    user_response = input() 
    user_response=user_response.lower() 
    if(user_response !='bye'): 
        if(user_response == 'thanks' or user_response == 'thank you'):
            flag=False
            print("BOT: You are welcome..") 
        else: 
            if(greet(user_response) !=None):
                    print("BOT: "+greet (user_response )) 
            else:
                    sent_tokens.append(user_response) 
                    word_tokens = word_tokens + nltk.word_tokenize(user_response)
                    final_words=list(set(word_tokens))
                    print("BOT:","end = ")
                    print(response(user_response))//HERE ERROR IS COMING
                    sent_tokens.remove(user_response)
else:
        flag = false
        print("BOT: GoodBye! See you Later")'''

I am getting above mentioned error for the commented line, but am not able to solve it. Any help will be appreciated

1 Answers

what is response in your code,is you getting value from request or httpx then you can't pass value to it. But you want to returning value as endpoint then you should define response with response.mimetype = "text/plain"

Related