In the following code, I would like to show the progress of two loops with the iteration number for the outer loop and dots for the inner loop.
import time
def foo():
for j in range(0,100):
if j % 10 == 0:
print('.', end='', flush=True, sep='')
time.sleep(0.2)
for i in range(0,100):
if i % 10 == 0:
print('\r', i, end='', flush=True, sep='')
time.sleep(1)
foo()
Although at i==10
it goes to the beginning of the line, it doesn't remove the dots. So, it actually overwrites the dots. See this figure:
Is there a way to clean the line and go to the start point with \r
?