Skip to content
Advertisement

Delete Characters in Python Printed Line

I’m writing a program where I want the cursor to print letters on the same line, but then delete them as well, as if a person was typing, made a mistake, deleted back to the mistake, and kept typing from there.

All I have so far is the ability to write them on the same line:

import sys, time
write = sys.stdout.write

for c in text:  
    write(c)
    time.sleep(.5)

Advertisement

Answer

write('b')  # <-- backup 1-character
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement