As the other answers said, use '\ b' to return. The trick in your case is to use sys.stdout.write instead of printing so as not to add a new line. Then wait and type in the appropriate number of inverse characters.
import time import sys print("Good morning!") while True: time_fmt = "It %I:%M:%S %p on %A, %b %d, %Y" time_str = time.strftime(time_fmt) sys.stdout.write(time_str) sys.stdout.flush() time.sleep(1) sys.stdout.write("\b"*len(time_str))
source share