Learn Python the Hard Way exercise 36 while loop
Question: The while loop in the dragon_room is not running and I'm not sure why. I get
the '>>' prompt over and over again and the program never exits or brings me
to another room.

    
    
    from sys import exit
    
    def food_room():
        print "This room is full of candy bars.  How many do you take?"
    
        next = raw_input("gold room> ")
        if "0" in next or "1" in next:
            how_much = int(next)
        else:
            dead("type a number.")
    
        if how_much < 5:
            dead("You've starved, sorry")
        else:
            print "You've survived! congratulations."
            exit(0)
    
    
    def bear_room():
        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 = raw_input("bear room >")
    
            if next == "take honey":
                dead("Apparently the bear is pretty protective of his honey")
            elif next == "taunt bear" and not bear_moved:
                print "The bear has moved from the door. You can go through it now."
                bear_moved = True
            elif next == "taunt bear" and bear_moved:
                dead("The bear gets pissed off and chews your face off.")
            elif next == "open door" and bear_moved:
                food_room()
            else:
                "no idea what that means."
    
    def dragon_room():
         print "You've opened the door on a giant, fire-breathing dragon."
         print "Do you flee or fight?"
         dragon_moved = False
    
         while True:
            next = raw_input(">>")
    
         if "flee" in next:
              start()
         elif next == "fight" and not dragon_moved:
              print "You have slayed the dragon!  There is a door behind him! you should open the door."
              dragon_moved = True
         elif next == "fight" and dragon_moved:
             dead("killed")
         elif next == "open door" and dragon_moved:
             food_room()
         else:
              dead("you're not very good at following instructions.")
    
    def dead(why):
        print why, "good job!"
        exit(0)
    
    def start():
        print "You are starving and in a dark room."
        print "There is a door to your right and left."
        print "Which one do you take?"
    
        next = raw_input(">")
    
        if next == "left":
            bear_room()
        elif next == "right":
            dragon_room()
        else: 
            dead("you starve.")
    
    
    start()
    


Answer: It looks like you've got an indentation error:

    
    
     while True:
        next = raw_input(">>")
     ## the loop above runs forever -- you probably want to indent all of the 
     ## below code to be inside the loop.
    
     if "flee" in next:
          start()
     elif next == "fight" and not dragon_moved:
          print "You have slayed the dragon!  There is a door behind him! you should open the door."
          dragon_moved = True
     elif next == "fight" and dragon_moved:
         dead("killed")
     elif next == "open door" and dragon_moved:
         food_room()
     else:
          dead("you're not very good at following instructions.")
    

