Search code examples
pythonprintingoverwrite

Overwrite previous print() python 3.9


I realise there are a number of answers to this question already online, however when trying \r it only goes to the end of the last line, rather to the very start of that line.

print("hello", end="")
print("\rthere")

ends up with:

hellothere

I've also tried

print("hello", end="\r")
print("there")

but with the same results. Everywhere I've looked has said that this should leave me with just 'there' which is what I want


Solution

  • Problem solved. Turns out as I was trying this in the IDE console which doesn't support the carriage return it just didn't create a new line, rather than returning to the start of the previous line