首页 > 解决方案 > 而用户输入变量可以是多个项目的函数?

问题描述

我最近开始使用 Zed Shaw 的书学习 Python。为了给其中一个练习(创建一个文本游戏)增加一些复杂性,我正在为每个进入的房间构建越来越复杂的可能性。在这里,我试图创建一个 while 语句来检查用户输入的 2 个变量。

在“While choice”行中,“go”起作用但“asd”不起作用。允许使用 while 语句使用多个用户输入的最佳方法是什么?我计划在另一个阶段将其更改为“if”语句,但在这种情况下,我想使用 while 语句来学习。

谢谢大家!

    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()

标签: python

解决方案


推荐阅读