-1

I am just starting to learn to code and I am experimenting with all sorts of methods. Might be a dumb question but why does this block only return the 0 value regardless of what I input?

start = input("Would you like to play? (Y/N)\n")
if start == "N" or "n":
    game_state = 0
elif start == "Y" or "y":
    game_state = 1
    

I have tried to change it in all sort of ways but I can t seem to make it work.

Mirciuca
  • 3
  • 1

1 Answers1

1

You need to change your if statements to:

if start == "N" or start == "n":

or to:

if start.lower() == "n":

A non-empty string will evaluate to True, so the first if statement will always run.

Tom McLean
  • 5,583
  • 1
  • 11
  • 36