4

I am working through Exercise 35 of Learn Python The Hard Way (LPTHW).

http://learnpythonthehardway.org/book/ex35.html

I am struggling with one of the study drills of this exercise. Specifically "Add more to the game".

Here is the code that is returning the error:

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."

1 Answer 1

8

It's next in ["taunt", "lure", "yell", "scream", "shout"]

not

["taunt", "lure", "yell", "scream", "shout"] in next

You have the test backwards.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks very much tested and confirmed to work! They still seem the same to me, obviously they are not but ok!
Order matters in this case, 'the key is in the lock' is not the same as 'the lock is in the key'. Also, remember to mark the answer as correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.