Introduction Variables Data Types Numbers Casting Strings Boolean Operators Lists Tuples Dictionaries If-Else While Loops For Loops Functions Arrays Scope Modules User Input File Handling Python Maths

Welcome to the lesson on Escape Sequences

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.

String Formatting

Some Examples: You will get an error if you use double quotes inside a string that is surrounded by double quotes:

syntax
Try it out yourself

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

Some Examples: The escape character allows you to use double quotes when you normally would not be allowed:

syntax
Try it out yourself

End of Escape Sequences

You have learned Escape Sequences in simple terms. Let's proceed on to Quiz.

Quiz Time!
Next Lesson
Back To Top