-1

I recently started my python course. I want to allow the user input again (back to the first line of question) after getting invalid inputs, therefore I added in the while loop. However, now, when the input is "yes", python prints out "I do not understand". Can I know what is wrong with the code and how should I fix it?

Here is the code

print('Hi, I am your bot, James!')

while True:
    user_reply=input("Are you ready for today's activity? ")
    if user_reply.lower == 'yes':
        for_calculation()

    elif user_reply.lower() == 'no':
        while True:
            double_confirm=input('Are you sure? ')
            if double_confirm.lower() == 'yes':
                print('See you next time.')
                exit()
            elif double_confirm.lower() == 'no':
                for_calculation()
            else:
                print('I do not understand.')

    else:
        print('I do not understand.')

And here's the result

Hi, I am your bot, James!
Are you ready for today's activity? yes
I do not understand.
Are you ready for today's activity? 
1
  • 1
    Replace if user_reply.lower == 'yes': with if user_reply.lower() == 'yes': Commented Sep 15, 2021 at 7:44

1 Answer 1

0

In if user_reply.lower == 'yes': you forgot the ():

if user_reply.lower() == 'yes':

If you do user_reply.lower, you are not getting the lowercase content of user_reply, you're getting the function itself that gives you the lowercase content. The () are very important because they tell Python not to just fetch the function, but to actually call it and give you the result.

Sign up to request clarification or add additional context in comments.

1 Comment

It's a duplicate though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.