0

I can't figure out why my code won't process the user input properly.

old = input("Type Yes or No.")

if old.upper() == "YES" or "Y":
    print("Success.")

When I type anything into the terminal, it still remains True for the old variable.

Ex. I type "sdafsdaf" into the terminal, and it still prints "Success."

Any solutions? Thank you

  • Could it be that the conditional is failing the initial equal check, but coercing the string "Y" to a Boolean? – Phix Dec 10 '19 at 02:46

1 Answers1

0
if old.upper() == "YES" or  old.upper() == "Y":

Your condition was wrong. "Y" will always evaluate to true, since a string / char datatype has a truthy value.

alex067
  • 3,159
  • 1
  • 11
  • 17