Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- def countdown(t):
- print("counting down")
- while t > 0:
- t2 = t # this preserves the countdown timer
- dayz = t2 // (24 * 3600) # captures the no of days
- t2 = t2 % (24 * 3600) # removes no of days from seconds
- hourz = t2 // 3600 # captures no of hours
- t2 %= 3600 # removes no of hours from seconds
- minutez = t2 // 60 # captures no of minutes
- secondz = t2 % 60 # removes no of minutes in seconds
- print("d:h:m:s-> %d:%d:%d:%d" % (dayz, hourz, minutez, secondz)) # %d is a placeholder for the follwoing 4 values
- sleep(1)
- t = t -1 # could write this as t -= t
- tgttimer = float(input("enter timer in seconds: ") )
- countdown(tgttimer)
- print("Times Up!")
Add Comment
Please, Sign In to add comment