Understanding and Using Escape Characters
In programming, an escape character is a symbol used to represent special characters or to change the typical meaning of characters within a string.
Escape characters are composed of a backslash (\
) followed by certain character(s).
Common Escape Characters
-
\n
: New Line -
\t
: Tab -
\\
: Backslash -
\"
: Double Quote -
\'
: Single Quote
Example of Using Escape Characters
print("Python\nProgramming Study!") # New line
print("This is\ta tab.") # Tab
print("She said: \"Hello!\"") # Double Quote
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.