Skip to content

Instantly share code, notes, and snippets.

@pbhalesain
Created February 19, 2023 08:51
Show Gist options
  • Select an option

  • Save pbhalesain/3b330f8a66db1cffd9dad08f99a8ae17 to your computer and use it in GitHub Desktop.

Select an option

Save pbhalesain/3b330f8a66db1cffd9dad08f99a8ae17 to your computer and use it in GitHub Desktop.
Python Countdown timer.
import time
def countdown(time_secs):
while(time_secs):
mins, secs = divmod(time_secs, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
time_secs -= 1
#print('stop')
num=int(input("Set your time in seconds: "))
countdown(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment