Last active
April 16, 2023 09:20
-
-
Save Igaryu/501c5ff31df925a1197b11e64c4c9bdf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from time import sleep | |
def countdown(t): | |
''' | |
Defines a countdown and prints always in the same position che counter | |
''' | |
while t: | |
mins, secs = divmod(t, 60) | |
timer = '{:02d}:{:02d}'.format(mins, secs) | |
print(timer, end="\r") | |
sleep(1) | |
t -= 1 | |
print('End of countdown.') | |
timeout = int(input("Enter the time in seconds: ")) | |
countdown(timeout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wonder why, if I set tabs as 2 spaces once confirmed and saved, the editor, transforms it into tab 8!!