0

I have a very simple question, that is puzzling me. I haven't used python before, and I just started a class today, and working on an assignment.

I need to take input, check if we want to continue or not. So I went ahead and checked if the input is != y or yes. I first wrote it out like such:

 continueprompt = str(input(CONTINUEMSG).lower())

 if  (continueprompt != "y" or continueprompt != "yes") :
     print("You've chosen to not continue")
     print("Exiting...")
     quit()

When I enter y or yes, it quits...? yet when I reform my statement to this:

 continueprompt = str(input(CONTINUEMSG).lower())


 if not (continueprompt == "y" or continueprompt == "yes") :
     print("You've chosen to not continue")
     print("Exiting...")
     quit()

Does python not like the != operator when comparing string? I'm new to Python, but I would think these two statements should execute the same, but it doesn't appear to be the case here.

Rickybobby
  • 245
  • 1
  • 13

0 Answers0