python - 无法弄清楚如何在 Python3 中重复过程
问题描述
我正在为一种爱好制作游戏,一种基于冒险文本的游戏。我不知道 id 是如何做到的,所以如果他们键入“起床”以外的任何内容,则该过程会重复,并且代码会再次询问他们,直到他们得到正确的答案。
getup = input("What is your action?: ")
if getup == "Get Up":
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "get up":
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "Get up":
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "GET UP":
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
else:
print("Celsia: You do not have time to waste,",name,"!!. You must Get Up")
解决方案
也许使用while
循环:
getup = input("What is your action?: ")
while getup.lower()!='get up':
print("Celsia: You do not have time to waste,",name,"!!. You must Get Up")
getup = input("What is your action?: ")
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
推荐阅读
- c++ - 将变量扫描到结构指针中时函数 get_dimensions() 中的分段错误
- python - 从 Django Channels 内部联系另一个 WebSocket 服务器
- sql - SQL - 根据名称在列中出现的次数找出如何编写 case 语句
- python - 有没有办法监控 BigQuery (GCP) 中数据集下的所有表/视图更新?
- c - 编译器如何区分同名项目
- javascript - JQuery/Javascript 无法在输出中正确显示样式和图像
- javascript - 使用浏览器 webRequest API 在 iframe 中加载任何网站?
- clickhouse - Clickhouse SQL 查询:间隔平均值
- azure - 命令“Get-AzFunctionApp”在 Azure 自动化 Runbook 中不起作用
- database - 在elasticsearch中存储搜索数据的推荐方法是什么