0

I'm very new to Python, so if this is a stupid question I apologize in advance. I'm playing around right now and writing a program that asks users to solve a riddle. Please note that the code I am about to paste is under a function, but I don't think that matters to share (right?). When I use this code, all works as intended-

    while True:
        answer = input("Option A: He stood on a block of ice until it melted. \nOption B: He floated through the water into the noose.\nWhich is the correct answer? ")
        if answer == "a":
            print("You are correct! On to the next riddle.")
            break
        else:
           print("You are incorrect. Try again.")
           continue

However, when I add an "or" statement so that the input can be "a" or "A", any input suddenly triggers the first print() statement and moves my program through to the next riddle. What is causing this to happen? Here's the code that is broken, in case it is important-

    while True:
        answer = input("Option A: He stood on a block of ice until it melted. \nOption B: He floated through the water into the noose.\nWhich is the correct answer? ")
        if answer == "a" or "A":
            print("You are correct! On to the next riddle.")
            break
        else:
            print("You are incorrect. Try again.")
            continue
julian salas
  • 3,714
  • 1
  • 19
  • 20

0 Answers0