Piotr Posted November 17, 2019 Report Share Posted November 17, 2019 Hello, I'm following video, and for some reason IF statement doesn't work properly: def flow_control(): answer = input("Do you want to learn about multiline text strings? (yes or no)") #if answer == "yes" or answer == "y": if answer == ("yes" or "y"): display_lesson() else: use_time() print("End program") Commented out IF statement works perfectly well, but 2nd one work only for "yes". How can i make it work? Quote Link to comment Share on other sites More sharing options...
administrator Posted November 17, 2019 Report Share Posted November 17, 2019 Looks like a line-break issue ... or indentation. Be sure the IF the block is properly indented. Stef Quote Link to comment Share on other sites More sharing options...
Piotr Posted November 18, 2019 Author Report Share Posted November 18, 2019 (edited) i'm using PyCharm, in such cases i have red underline and code would not run properly. I replaced tabs with 4 spaces, but it did not help at all. if answer == ("y" or "yes"): display_lesson() I have replaced "y" with "yes" so answer is True only for "y" because for "yes" it going to else statement. It looks my IDE does not consider "or". PS. i was fooling around and changed or to and. In that case for answer is True for "yes". Anyhow ill back to version without parentheses, just was curious what is going on in background. Piotr Edited November 18, 2019 by Piotr Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.