python - 而用户输入变量可以是多个项目的函数?
问题描述
我最近开始使用 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()
解决方案
推荐阅读
- sublimetext3 - 在 Sublime Text 3 中粘贴一些文本时,如何用直引号 (') 替换智能引号 (')?
- php - 我想将一个字符串分成两部分,数字之前和数字之后
- stripe-payments - 使用 Retrieve Payment Intent 或 Retrieve Checkout Session 验证 Stripe Payment?
- c++ - 如何将指针转换为我在 C++ 中输入的类型?
- makefile - 我对makefile的一些东西感到困惑
- swift - SwiftUI textView onChange 无法正常工作
- sql - 自动将数据从 CSV 文件发送到 SQL Server?
- xamarin.forms - 如何在 Xamrin IOS customrenderer 中单击 UITextField 的 Rightview 打开 UIPickerView
- java - 为什么这段代码不能在 Java 中运行?错误:
预期的 - apache-spark - 为什么 pyspark write() 比 show() 慢?