0

I have recently started learning Python using Zed Shaw's books. In an attempt to add some complexity to one of the exercises (creating a text game) I am building more and more complex possibilities with each room entered. Here, I am trying to create a while statement that checks for user input for 2 variables.

In the "While choice" line, "go" functions but "asd" does not. What is the best way to allow multiple user inputs to be used using a while statement? I plan on changing this in another stage to an "if" statement, but in this scenario I want to use a while statement to learn.

Thank you everyone!

    print("""
    Instructions:
    Use simple verb noun commands such as;
    move book
    go stairs
    look vase
    There are other hidden verbs and nouns. Try a few!
    You might learn something no one else has!
    """
    )
    
    choice = ""
      
    while choice != ("go" or "asd"):
        choice = input("Type 'go' to the continue >")
    return tombs()
    
instr()
CanisVY
  • 11
  • 2
  • I say remove the question because it is so basic: `while choice != "go" and choice != "asd":` – M.Mavini Oct 16 '21 at 06:16
  • 1
    `while choice not in ("go", "asd"):` is much better (scalable) – mozway Oct 16 '21 at 06:18
  • I came to edit my OP because I realized I forgot things I tried. Mavini - I tried that with or, that makes sense now why it would work that way. mozway - I did not even know not in worked. I'm going to use both of these throughout what I write. Thank you very much! – CanisVY Oct 16 '21 at 06:26

0 Answers0