This has been asked before (for instance a, b, etc.), but I cannot make it work in IPython console. I simply want to print some text over and over on the same line, not as continuous text, but replacing the previous one. This is my code:
import time
try:
while True:
s = "I want this always on the same line. "
print(s, end="\r", flush=True)
time.sleep(0.5)
except KeyboardInterrupt:
pass
And here is what I get in IPython console:
I am using Anaconda distribution on PC and Spyder, with Python 3. The code works in Anaconda terminal, but I need to print out some image as well so I need IPython. I also tried using end=""
or adding a comma after the print()
statement (even if this is for Python 2), but to no avail.