My goal is to show a loading progress in my console by overwriting the previous line with the current progress. I have found plenty of solutions for version 3 of Python, but those are not working.
For instance:
import time
for i in range(10):
print(i, end='', flush=True)
time.sleep(1)
Gives me the following output:
0123456789
Or both:
import time
for i in range(10):
print(i, end='\r', flush=True)
time.sleep(1)
and:
import time
for i in range(10):
print("\b" + str(i), end='', flush=True)
time.sleep(1)
Gives me the following output:
0
1
2
3
...
Any idea ? I am working under PyCharm Community Edition with the Anaconda package.
Many thanks!
EDIT: the problem does not seem to happen when I run a python file (using PyCharm), but only when I do "Execute Selection in Console"