Created
February 19, 2023 08:51
-
-
Save pbhalesain/3b330f8a66db1cffd9dad08f99a8ae17 to your computer and use it in GitHub Desktop.
Python Countdown timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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