I saw in another question that ("\b"
) could be used to delete a character. However, when I tried \b
it only put a space in between the character I was intending on deleting and the one after. Is there another way I could do backspace?
(I'm trying to make a program that will write a word, delete it then rewrite a new one)
It depends on the terminal which is used and how it interprets the \b
, e.g.
print('Text: ABC\b\b\bXYZ')
in the interactive console of PyCharm gives:
Text: ABC XYZ
but executed in the comand line (cmd.exe) it gives:
Text: XYZ
This is explained in more detail here: https://stackoverflow.com/a/19926010/5276734