I want to make a game in the python console, so I need to write out lines, and then re-write them. I started building up code for it, and came up with this:
import sys
while 1:
#I will calculate what to write here, and store it in display
display = ["thing", "other thing", "2nd other thing"]
#Move the writing start back to the beginning
for x in display: sys.stdout.write("\r")
#Write the contents of display
for x in display: sys.stdout.write(x + "\n")
However, the code does not erase the previously written text. It just repetitively prints the display list. How can I make it erase the text?