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 come my if statement isn't working properly?

Python code

IDLE Shell Python

I’m a very beginner coder, so bear with me, but my if statement is printing out even when the required name isn’t typed in. For example, if I typed in Apple, it would still print out Charmander and Charmeleon.

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

I tried assigning my if statement to input, name, but nothing seems to work, and I’m at a loss for ideas. 

>Solution :

Try using name.lower() so your input will be in lower case and then compare it only with "charmender"

if name.lower()=="charmender":
    print('A')
elif name.lower()=="charmeleon":
    print('B')
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