📚
Escape Characters
Special Characters in Strings
Sometimes you need characters that you can't just type — like a line break in the middle of a string, or a tab for indentation. Python uses escape sequences starting with a backslash
\\| Escape | What it produces | Example |
|---|---|---|
| New line | |
| Tab (indent) | |
| Double quote | |
| Single quote | |
| Backslash | |
print("First\nSecond") # Two lines print("Name:\tAlice") # Tab-indented
💡💡 The
(newline) is by far the most commonly used escape character. You'll see it everywhere in Python!\\n
main.pySandbox
main.py
Ctrl + Enter