Why is nothing happening when i run this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Johnson
    New Member
    • Dec 2011
    • 8

    Why is nothing happening when i run this?

    Code:
    from sys import exit
    from random import randint
    
    
    def main_hall():
        print "You are on the war ship. You need to get into the elevator to get to the bridge; where the General is."
        print "The whole destroyer is on alert and nearly every door is locked. There is a keypad on the elevator."
        print "There is a warning saying you only have 10 attemps, then the system deactivates and you cannot complete your mission. Be careful!"
        
        combination = "%d%d%d"  % (randint(1,9), randint(1,9), randint(1,9))
    
        guess = raw_input ("[Keypad:] ")
    
        guesses = 0
    
        while guess != combination and guesses < 10:
            print "*BZZT!* ERROR 2355: Incorrect combination!"
            guesses += 1
            guess = raw_input
    
        if guess == combination:
            print "You open the elevator and start going up, fast. When you get to the top, you are at a T-junction. Do you go left or right?"
            return 'junction'
    
        else:
            print "You have had more than 10 attempts! \n A small self destruct system in the lock blows you up!\n"
            return 'death'
            
            
    
    
    
    def death():
        lols = ["NO! You have failed this mission!", "Game over kid!", "You are really bad.", "Mission over, you may aswell go home."]
        print lols(0, len(lols)-1)
        exit (1)
    This is my version of a game. i am doing it for an exercise for learn python the hard way, a book tutorial.

    Why does nothing happen? There are no error messages, just nothing happens.... thanks!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You never call your main_hall function.

    Comment

    • Daniel Johnson
      New Member
      • Dec 2011
      • 8

      #3
      How do i do that? im not very good at python yet

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        By typing in the name of the function.

        Code:
        def hello():
            print "Hello World!"
            return
        
        hello()

        Comment

        Working...