[Python] OR operator use with string input [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create simple question game. In this player will have 2 options and right option will lead to treasure. i am trying to use OR operator with string input but i am looking or 3 possible input. If I have one of the 3 input the output will be executed. My output is only executed with 1 input only not with other 2.

    please find my sample code attached.

    if key_direction == ('left' or 'Left' or 'LEFT'):
    print("You are seeing a flock of crow. In the midlle you see a basket guarded by the crows. It has a key in it.")
    crow = input("Do you have something for crows?(Y/N)")
    if crow == ("bread" or "Bread"):
    print("Crows are now distracted in eating bread. Quickly take key and leave.")
    elif crow == ("No" or "N"):
    print("You are attacked by crows. You died. please try again.")
    else:
    print(" Yu forgot the path and lost. Please start again.")
    else:
    print(" You forgot the path and lost. Please start again.")

    Continue reading...

Compartilhe esta Página