这段代码是完美的工作,但我想知道我是否可以得到相同的功能使用for循环?你知道吗
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")
对于这段代码,您不能将input用作变量,因此我将其重写为:
至于暴风雨,英国人会说:暴风雨已经停止了。尽管如此,我认为你在elif中意外地颠倒了not(storm)和storm,这是偶然的——从等价物的意义来看。你知道吗
希望这能帮助你理解。要做到这一点,其实没有太多其他的方法,也绝对没有更简单的方法。你知道吗
相关问题 更多 >
编程相关推荐