【发布时间】:2019-04-19 15:42:24
【问题描述】:
这段代码运行良好,但我想知道是否可以使用 for-loop 获得相同的功能?
storm_halted=False
while True:
input=raw_input("> ")
if "stay" in input:
print dead("You were struck by lightning !")
elif "wait" in input and not storm:
print "The storm has stpped !"
storm_halted=True
elif "wait" in input and storm:
print dead("You are lazy")
elif "room" in input and storm :
gold ()
else:
print dead("Type something")
【问题讨论】:
-
请详细说明您的需求。您要解决的具体问题是什么。如果这是作业,请先展示你的一些尝试。
-
storm未定义,您的函数永远不会被调用。请提供符合How to create a Minimal, Complete, and Verifiable example 的代码和明确表述的“我得到的是这个” 和“我想要的是那个”(如果适用:“这个是我的错误消息和堆栈跟踪” 我的代码产生)
标签: python while-loop boolean