擅长:python、mysql、java
<p>首先我注意到,如果你第二次输入switch两次,你的程序就会发现它是一个错误。
我认为问题出在action\u error函数的末尾,您将返回值赋给prompt(),因此输入过早地被使用。你知道吗</p>
<p>可能的解决方法是:</p>
<pre><code>def action_error(custom=False):
if custom != False:
print(custom)
else:
phrases = ["A bunch", "of funny", "error phrases"]
print(phrases[randint(1, len(phrases)-1)])
while True:
action = prompt()
print(action) #Debugging purposes
if action.find("switch") != -1:
if action.find("light") != -1:
second_room() #Story continues
else:
action_error("What do you want to switch?")
else:
action_error()
</code></pre>
<p>因此,在while循环的开头没有action\u error()和direct赋值的返回值。你知道吗</p>