Skip to content

Instantly share code, notes, and snippets.

@embayer
Created February 4, 2017 15:54
Show Gist options
  • Save embayer/25f4ceb2f6d7c5504802eac432abbb25 to your computer and use it in GitHub Desktop.
Save embayer/25f4ceb2f6d7c5504802eac432abbb25 to your computer and use it in GitHub Desktop.
render a countdown on the commandline
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