Stopping a timer with a specific code
Question: I'm trying to make a Bomb timer than can be stopped at any given moment using
a specific code. which is 7355608

I've tried doing this but I fail at it, also please keep in mind I'm
relatively new to python.

Also, thanks in advance.

    
    
    import time
    
    def countdown():
        for n in range(45, 0, -1):
            print n
            time.sleep(1)
            code = int(raw_input("Enter code:"))
            if code == passcode:
                break
    countdown()
    passcode = 7355608
    

P.S: I know the code is really bad, because I'm new to python.


Answer: You need to tell the program what "passcode" is before the countdown() method
definition, or else python doesn't know what "passcode" means. Just move the
statement "passcode = 7355608" to above the method block and it should work!

