Skip to content

Commit

Permalink
countdown - python
Browse files Browse the repository at this point in the history
  • Loading branch information
playatanu committed Oct 12, 2024
1 parent 809aecf commit 4909151
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Python/countdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import time

def countdown(time_sec):
while time_sec:
mins, secs = divmod(time_sec, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
time_sec -= 1

print("stop")

countdown(5)

0 comments on commit 4909151

Please sign in to comment.