I am learning to program through python, and I recently got stuck for the first time. For this exercise, we must write our own game. I did this, but for some reason, whenever I run it, the right_room () function ends after I answer, instead of moving to the next room. Any help would be greatly appreciated. Here is my code:
from sys import exit def bear_room(): print "You are in a room with a bear." print "You have two choices. left or right?" next = raw_input("> ") if next == "left": left_room() elif next == "right": right_room() else: print "No idea what that means..." def left_room(): print "You went left." print "There are two doors. right or straight" next = raw_input("> ") if next == "right": bear_room() elif next == "straight": second_left() else: print "What are you saying, bro?" def second_left(): print "You went straight." print "You again have two choices. straight or right?" next = raw_input("> ") if next == "straight": print "You won! Congrats." exit(0) elif next == "right": dead("You opened the door and walked off a cliff. Goodbye!") else: print "I didn't quite catch that." def right_room(): print "You went right." print "There are two doors. straight or right?" next == raw_input("> ") if next == "right": dead("Oops, a tiger just ate you") elif next == "straight": second_right() else: "What?!?!?!" def second_right(): print "You went straight" print "Nice choice." print "You have two choices: left or straight" next == raw_input("> ") if next == "left": dead("You just fell 1 million feet to your death.") elif next == "straight": print "You made it out alive!" exit(0) else: "WTF?" def dead(reason): print reason, "good job!" exit(0) def start(): print "You are about to enter a room." bear_room() start()
source share