Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2023 11:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save RDCH106/3855cdf3201fcba7ef3356d9931d1a4c to your computer and use it in GitHub Desktop.
Simple and configurable countdown for the Command Line Interface (CLI)
# -*- coding: utf-8 -*-
import time
def countdown_sleep(second: int):
# check second is natural number (contains 0)
if not isinstance(second, int) or second < 0:
raise ValueError("'second' should be a natural number (contains 0). second: %s" % second)
# countdown
for i in range(second, 0, -1):
print(f"\rWait... {i} ", end="", flush=True)
print(f"\rGo! ", flush=True)
# Try countdown
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment