First of all, as mentioned at this thread, backspace isn't meant to erase the character to the left. It is meant to act only as the "left arrow". EDIT: as mentioned in OP's comment below, in Jupyter notebook this doesn't seem to hold -- the \b
does have the effect of erasing, in Jupyter notebook.
Secondly, there seems to be some anomaly in the behavior of backspace as seen on Jupyter notebook. (I couldn't find the anomaly when I ran the same tests by simply running python on the conda prompt on my Windows, and the behavior was exactly as expected). The anomaly is that, an odd number of consecutive backspaces seems to behave exactly like a single backspace, and an even number of backspaces seems to always behave like two consecutive backspaces. As I said, on raw Python on the conda prompt, the effect of 3 consecutive backspaces is different from the effect of a single backspace, and that is how it is supposed to be.
Here's the test I ran, first as a code snippet in a Jupyter notebook cell, and second as a Python script on the conda prompt:
print('00hello goodbye')
print('01hello\b goodbye')
print('02hello\b\b goodbye')
print('03hello\b\b\b goodbye')
print('04hello\b\b\b\b goodbye')
print('05hello\b\b\b\b\b goodbye')
print('06hello\b\b\b\b\b\b goodbye')
print('07hello\b\b\b\b\b\b\b goodbye')
print('08hello\b\b\b\b\b\b\b\b goodbye')
Output in Jupyter notebook:
00hello goodbye
01hell goodbye
02hel goodbye
03hell goodbye
04hel goodbye
05hell goodbye
06hel goodbye
07hell goodbye
08hel goodbye
Output on command prompt:
00hello goodbye
01hell goodbye
02hel goodbye
03he goodbye
04h goodbye
05 goodbye
0 goodbye
goodbye
goodbye
EDIT: To summarize the above rant, the behavior is very different in Jupyter notebook vs command prompt. And the difference is in two aspects (a) Backspace acting as an erase (b) Multiple consecutive (odd or even number of) backspaces getting collapsed into 1 or 2 backspaces. Both these anomalies don't seem to exist on the command prompt.