Created
February 4, 2017 15:54
-
-
Save embayer/25f4ceb2f6d7c5504802eac432abbb25 to your computer and use it in GitHub Desktop.
render a countdown on the commandline
This file contains 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
def countdown(timeout): | |
''' render a countdown on the commandline | |
''' @param timeout: minutes to count down | |
while timeout: | |
mins, secs = divmod(timeout, 60) | |
cntdwn = '{:02d}:{:02d}'.format(mins, secs) | |
print(cntdwn, end='\r') | |
sleep(1) | |
timeout -= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment