Back to Python Notes
Topic #22

Escape Characters

Escape characters let you include quotes, newlines and tabs inside strings. Without them, some of the simplest text becomes impossible to write.


Escape Character

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.

An example of an illegal character is a double quote inside a string that is surrounded by double quotes:

Example

txt = "We are the so-called "Vikings" from the north."

To fix this problem, use the escape character \":

Example

txt = "We are the so-called \"Vikings\" from the north."

Escape Characters

Other escape characters used in Python:

Code Result Try it
' Single Quote
\ Backslash
\n New Line
\r Carriage Return
\t Tab
\b Backspace
\f Form Feed
\ooo Octal value
\xhh Hex value

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Escape Characters – FAQs

Quick answers about learning Escape Characters in Python.

This free note from Coding Now Tech Institute explains Escape Characters in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Escape Characters, is 100% free with no signup required.
With focused practice, most students grasp Escape Characters in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now