Python Countdown Timer includes Extra Zero
Question: I'm attempting to make a timer that, once inputing any amount of minutes, the
window will count down the time in a mm:ss format. however, when inputing a
time over 10 mins, when the minutes get below 10 after starting at any time
above 10 minutes, an extra zero appears at the end of the timer. I cannot seem
to figure out how to get rid of it and was hoping for another set of eyes to
see if I've made any silly mistakes.

    
    
    import time, sys, os
    os.system("cls")
    def countdown_screen(endtime):
        sectot=int(endtime)*60
        print("*******************************************************************************")
        for i in range(0,sectot):
            mins=(int(sectot)/60)
            secs=sectot-(mins*60)
            if secs<10:
                secs="0"+str(secs)
            if mins==10 and secs==0:
                secs=secs-"0"
            sys.stdout.write("\rSystem standby for: %s:%s" %(mins,secs))
            sys.stdout.flush()
            time.sleep(1)
            sectot=sectot-1     
        sys.stdout.write("\rSystem standby complete.")
        print""
    endtime=raw_input("mins:")
    countdown_screen(endtime)
    


Answer: You are overloading `secs` to be an int and then a string, that's sure to be a
problem:

    
    
        if secs<10:
            secs="0"+str(secs)
        if mins==10 and secs==0:
            secs=secs-"0"
    

But you should simplify your whole approach and let string formatting do the
work for you:

    
    
    import time, sys, os
    os.system("cls")
    def countdown_screen(endtime):
        sectot=int(endtime)*60
        print("*******************************************************************************")
        for i in range(0,sectot):
            sys.stdout.write("\rSystem standby for: %02d:%02d" % (sectot/60,sectot%60))
            sys.stdout.flush()
            time.sleep(1)
            sectot=sectot-1     
        sys.stdout.write("\rSystem standby complete.")
        print""
    endtime=raw_input("mins:")
    countdown_screen(endtime)
    

