我正在通过练习35学习Python的艰难之路(LPTHW)。
http://learnpythonthehardway.org/book/ex35.html
我正在努力学习这项练习的其中一项练习。特别是“为游戏添加更多”。
以下是返回错误的代码:
def bear_room(): # A new encounter
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move the bear?"
bear_moved = False
while True:
next = str(raw_input("> "))
if ["honey", "take"] in next:
dead("The bear peers at you for a moment, sizing you up, then claws your face off.")
elif ["taunt", "lure", "yell", "scream", "shout"] in next:
print "the bear has moved from the door. You can go through it now."
bear_moved = True
elif ["taunt", "lure", "yell", "scream", "shout"] in next and bear_moved:
dead("The bear gets pissed off and chews your leg off.")
elif ["open", "door", "next", "through", "onward"] in next and bear_moved:
gold_room()
else:
print "I got not idea what that means."
答案 0 :(得分:4)
这是
next in ["taunt", "lure", "yell", "scream", "shout"]
不
["taunt", "lure", "yell", "scream", "shout"] in next
你倒退了测试。