Skip to content

Instantly share code, notes, and snippets.

@akasakaid
Created May 2, 2024 14:55
Show Gist options
  • Select an option

  • Save akasakaid/ba18fad1447e7598fe2acdf35cf2aeeb to your computer and use it in GitHub Desktop.

Select an option

Save akasakaid/ba18fad1447e7598fe2acdf35cf2aeeb to your computer and use it in GitHub Desktop.
countdown with python
def countdown(t):
while t:
menit,detik = divmod(t,60)
jam,menit = divmod(menit,60)
jam = str(jam).zfill(2)
menit = str(menit).zfill(2)
detik = str(menit).zfill(2)
print(f'waiting until {jam}:{menit}:{detik} ',flush=True,end='\r')
t -= 1
time.sleep(1)
print(' ',flush=True,end='\r')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment