See the string literal documentation:

\b ASCII Backspace (BS)

It produces a backspace character. Your terminal backspaced over the second o when printing that character.

Answer from Martijn Pieters on Stack Overflow
🌐
W3Schools
w3schools.com › python › gloss_python_escape_characters.asp
Python Escape Characters
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... To insert characters that are illegal in a string, use an escape character. An escape character is a backslash \ followed by the character you want to insert.
Discussions

Slash vs backslash to separate folders
but whenever I copy a file address in Windows it copies with the folders separated by backslashes You should use an appropriate type for file paths, such as pathlib or os.path (low level), which handles the directory separators for you. https://docs.python.org/3/library/pathlib.html More on reddit.com
🌐 r/learnpython
7
3
February 1, 2024
how to solve Ax=b without backslash operator and inv() function?
How would you go about solving this by hand? Once you have that, it is just a matter of implementing it in matlab. More on reddit.com
🌐 r/matlab
8
3
September 9, 2022
What is \b realistically used for?
The other time you might want to use it is if say you had a string which said "loading..." and then had say a percentage or a "text spinner" at the end (i.e. loops through | / - \ |). You can print the \b character however many times required to only update that bit of text on the screen, eliminating (or at least vastly reducing) flickering/refreshing/repetition of text. from time import sleep s="|/-\\" print("Loading....", end="", flush=True) for i in range(20): print(f"\b{s[i%len(s)]}", end="", flush=True) sleep(0.5) (Edit) included flush=True as per suggestions. More on reddit.com
🌐 r/Python
49
273
December 24, 2021
[Python] cómo encontrar una barra diagonal inversa simple ...
That's because just typing x doesn't show you the string. It shows you repr(x), which shows you the escape sequences so you can more readily tell what's in the string. >>> x = '\thello' >>> x '\thello' >>> print(x) hello · If you print x (the way you'd need to do in a real program- just leaving the bare variable only does something in the interactive console), it'll only show a single backslash... More on reddit.com
🌐 r/learnprogramming
February 16, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-escape-characters
Python Escape Characters - GeeksforGeeks
April 28, 2025 - The \b escape character moves the cursor one character back, effectively deleting the last character. ... The \f escape character moves the cursor to the next page (less commonly used in modern programming).
🌐
Python Morsels
pythonmorsels.com › raw-strings
Raw strings - Python Morsels
August 12, 2021 - Because those \b represent an escape sequence, they don't end up giving us any matches. Whenever I'm making a regular expression in Python, I always prefix it with an r (just in case). Raw strings are a way of making a string in Python that has no escape sequences and instead reads every backslash as a literal backslash.
🌐
Imperial College London
python.pages.doc.ic.ac.uk › 2022 › lessons › regex › 04-boundary › 03-boundary.html
Advanced Lesson 1: Regular Expressions > Word boundary | Python Programming (70053 Autumn Term 2022/2023) | Department of Computing | Imperial College London
Note: you need to be careful when implementing this in Python. \b is actually the backspace character. So you will have to escape the backslash by using \\b instead, i.e. "\\bred\\b". Alternatively and preferably, use a Python raw string literal: r"\b" is equivalent to "\\b".
🌐
Python documentation
docs.python.org › 3 › reference › lexical_analysis.html
2. Lexical analysis — Python 3.14.6 documentation
Tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight (this is intended to be the same rule as used by Unix). The total number of spaces preceding the first non-blank character then determines the line’s indentation. Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation.
Find elsewhere
🌐
Quora
quora.com › How-do-you-backslash-a-string-in-Python
How to backslash a string in Python - Quora
Scale everything in one click. Explore VPS plans. ... To include literal backslashes in Python strings you must escape each backslash (write \) or use raw string literals when appropriate.
🌐
GitConnected
levelup.gitconnected.com › escaping-backslash-hell-in-python-0550bc7a2db3
Escaping Backslash Hell in Python | by Liu Zuo Lin | Level Up Coding
October 24, 2024 - The \ (backslash) character is used to escape other characters — \n (newline), \t (tab) and so on. So if we want to print \, we need to use another \ to escape it: ... If we want to print \\\, we need one \ each to escape each \ — meaning ...
🌐
freeCodeCamp
freecodecamp.org › news › escape-sequences-python
Escape Sequences in Python
January 3, 2020 - Escape sequences allow you to include special characters in strings. To do this, simply add a backslash (\) before the character you want to escape. For example, imagine you initialized a string with single quotes: s = 'Hey, whats up?' print(s) Outp...
🌐
LearnByExample
learnbyexample.github.io › py_regular_expressions › escaping-metacharacters.html
Escaping metacharacters - Understanding Python re(gex)?
However, \b is for word boundaries as seen earlier, whereas it stands for the backspace character in normal string literals. The full list is mentioned at the end of the docs.python: Regular Expression Syntax section as \a \b \f \n \N \r \t ...
🌐
InterServer
interserver.net › home › python › how to use escape characters in python strings effectively
How to Use Escape Characters in Python Strings Effectively - Interserver Tips
January 8, 2026 - This may cause an error because \U starts a Unicode escape sequence. To avoid this, use double backslashes: ... This tells Python to treat each backslash literally.
🌐
Python Examples
pythonexamples.org › python-escape-characters
Python Escape Characters
To specify a byte using hex value, use a preceding backslash and x for two digit hex value in the string. ... Hex value of 41 means 65 in decimal. And a byte with decimal 65 represents the character A. Similarly 42 is B, 43 is C. In this tutorial of Python Examples, we learned what escape characters are, how to use them in a string, and their usage, with the help of example programs for each of the escape characters.
🌐
MojoAuth
mojoauth.com › special-characters › backspace-b-in-python
Backspace (\b) in Python | Understanding Special Characters in Programming
The backspace character, represented as \b, is an important control character in Python that allows for the manipulation of text output in a terminal or console. When \b is utilized in a string, it moves the cursor one position back, effectively ...
🌐
Python Forum
python-forum.io › thread-37781.html
change backslash into slash in a path
July 21, 2022 - Hi Typically in a Windows path, I want to change the special 'backslash' character to 'slash' one. I was thinking re.sub substitutes all occurences but whatever I've tested so far, it fails (same result using replace()): what I'm missing? Path = 'D...
🌐
Python documentation
docs.python.org › 3 › howto › regex.html
Regular expression HOWTO — Python 3.14.6 documentation
Let’s say you want to write a RE that matches the string \section, which might be found in a LaTeX file. To figure out what to write in the program code, start with the desired string to be matched. Next, you must escape any backslashes and other metacharacters by preceding them with a backslash, resulting in the string \\section.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.6 ...
3 weeks ago - However, Unicode strings and 8-bit ... use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning....
🌐
TOOLSQA
toolsqa.com › python › escape-sequences-in-python
Escape Sequences in Python (with examples) - ToolsQA
That is to say; backlash signifies that the next character after it has a different meaning. It could be printing double quotes or indicating a new line. Let's see what escape sequences are and how to use them in Escape Sequences in Python. The sequence of characters after a backslash is known as an escape sequence.
🌐
Scaler
scaler.com › home › topics › escape sequence in python
Escape Sequence in Python - Scaler Topics
April 23, 2024 - It happened because of the backslash (‘\’) before any character tells the interpreter that this combination is an escape sequence in python, removing the backslash from the string and putting the quote inside the string.
🌐
Medium
medium.com › @20pa1a0594 › python-escape-characters-302187d8e507
Python Escape Characters. Escape characters in Python are special… | by MANNAM BHARGAVI | Medium
May 30, 2024 - Escape characters in Python are special characters that are preceded by a backslash (\). These characters are used to represent certain whitespace or non-printable characters within string literals.