3
我想知道如何在赋值之前使用if语句来更改它。这个脚本的目的是在提示问题从桌面上拿下之前检查刀是否被拿走。这是为了让你可以走回桌子,如果你已经采取了另一种回应。我究竟做错了什么?根据变量更改响应
def table():
if knife_taken == False:
print "it's an old, brown wooden table, and atop it you find a knife"
print "Will you take the knife or go back?"
knife = raw_input ("> ")
if knife.strip().lower() in ["back", "b", "no"]:
basement2()
elif knife.strip().lower() in ["take knife", "knife", "yes", "k"]:
knife_taken = True
print "You now have the knife, good, you are going to need it"
raw_input()
basement2()
else:
print "I did not understand that."
raw_input()
table()
else:
print "There's nothing on the table"
raw_input()
basement2()
+1为字典! – poke
@poke当你有一个友好的动态语言时,生活变得有趣 –
谢谢!像魅力一样工作! –