Jump to content
Stef's Coding Community

Chapter 5.6 conditional statement not working properly

Recommended Posts


Lesson 6 contains a simple game where we define a flowControl() function with the following "if...else" statement:

if answer == ("yes" or "y"):
        print("End program")

If we run the module and input "yes" the statement is true but if we input "y" then we get the false/else statement.  Only the first parameter is considered apparently, if we swap them ("y" or "yes") then "y" would be considered true and "yes" false.

I found that if we remove the round brackets from that line and change the statement to:

if answer == "yes" or "y"

then both parameters work, "yes" and "y" are then considered as a true statement.

Not a big deal, just thought i should mention it.



  • Like 1
Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...