0

I want to have a loop which does something according to Y/N input. If I use .upper / .lower, the loop does not work and always goes into the first if, no matter the input. Why is that?

Here's and example of how it doesn't work:

answer = input("Do you want to begin? (Y/N): ")
if answer or answer.lower() in ("y", "yes"):        
    print("Start")
else:
    print("Bye")

If I write it like this, it works fine.

if answer in ("y","Y","yes","Yes","YES"):

This I found online as solution, but doesn't work for me:

if answer.upper() or answer.lower() in ('y', 'yes'): 

Am I just missing something or did anyone else have this issue? Thanks for the help

atin
  • 985
  • 3
  • 11
  • 28

0 Answers0