I'm trying to print in Jupyter Lab in the same line, but clearing the previous output. I'm aware of the '\r'
escape character and that I can do print('\r'+ my_string,end='')
and it works. The thing that I want to know is how can I completely erase the previous output, because when my_string
has less characters, the characters from previous line output remains at the end of the line.
For example:
my_string = '\r{}%'
for i in range(10000,-1,-1):
print(s.format(i/100),end='')
The final output for this would be 0.0%%%, instead of 0.0%
I tried this SO post, but it didn't work for me :(
EDIT: What I'm trying to accomplish is something like this:
my_string = '\rLap {} || {}%'
for lap in range(3):
for i in range(10000,-1,-1):
print(my_string.format(lap,i/100),end='')
print()
Actual output:
Lap 0 || 0.0%%%
Lap 1 || 0.0%%%
Lap 2 || 0.0%%%
Desired output:
Lap 0 || 0.0%
Lap 1 || 0.0%
Lap 2 || 0.0%