Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I get this If statement condition to work properly?

I’m having a problem with the following piece of code:

decision = str(input("Would you like to change it?:"))
if decision.lower == 'yes':
    new_holiday = input("What is your new favorite holiday?:")

The problem with this is that when I input ‘yes’ in the first prompt, instead of showing me the second one as I want, it just skips the if statement completely. Am I missing something here?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

decision.lower generates a method <built-in method lower of str object at ...>. you should call decision.lower().

Change your code to the following:

decision = str(input("Would you like to change it?:"))
if decision.lower() == 'yes':
    new_holiday = input("What is your new favorite holiday?:")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading