\r
brings you to the beginning of the line where you will start overwriting stuff.
\n
adds a newline
\n\r
takes you to the next line, and then bring you to the beginning of that line, which is already a blank new line, and so the \r
isn't actually doing anything and this is the same as just doing \n
.
If you only wish to overwrite a single line you can do this with \r
followed by your text. Make sure that whatever you print out has enough spaces at the end of it to make it the same length as the line you are overwriting, otherwise, you'll end up with part of the line not getting overwritten.
But since you've clarified that you need to overwrite multiple lines, things are a little bit trickier. Carriage returns (\r
) were originally created to help with problems early printers had (This Wikipedia article explains these problems). There is a completely different mechanism for overwriting multiple lines that isn't exposed natively by Python, but this Stack Overflow question lists a few 3rd party libraries you can install that will help you accomplish this.