One way to get something close to what you want is if the terminal supports ANSI cancel codes :
x = input("My score is \x1b[s of 10\x1b[u")
\x1b
is an escape character. Not a single escape character is displayed on the screen; instead, they enter sequences of bytes that the terminal interprets as some kind of instruction. ESC[s
tells the terminal to remember where the cursor is. ESC[u
tells the terminal to move the cursor to the last saved position.

(A rectangle is a cursor in an unfocused window.)
Using a library that abstracts the exact terminal you are using is preferable, but it gives you an idea of how such libraries interact with your terminal: they are all just bytes written to standard output.
source share