Issue
I would love to print a counting down and in each second delete a line:
import time
for x in range(3):
print(x)
time.sleep(1)
#Delete previous line
How can I do? Thanks
Solution
It all depends what terminal are you using. You can simulate the deletion of the line with carriage-return characters \r
and spaces ' '
, for example:
import time
for x in range(3):
print(x, end='', flush=True)
time.sleep(1)
print('\r \r', end='', flush=True)
For more advanced solution, look at the curses
module.
Answered By - Andrej Kesely Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.