Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Quick recap
5. Escaping characters
Indexing and slicing
Summary

Instruction

Good job! The backslash (\) is a character used to "escape" special characters. Take a look:

introduction = 'Hello, I\'m John!'

This will print:

Hello, I'm John!

Normally, an apostrophe is interpreted as the end of a string. That's why we need to "escape" it with a backslash. The backslash itself won't be printed, but the apostrophe will.

The backslash is a special character itself. To escape it, you need another backslash:

print('This is a single backslash: \\')

This will print:

This is a single backslash: \

Exercise

Store the following sentence in a variable named language_tip:

Instead of "dos and don'ts", some people tend to write "do's and don'ts". To be consistent, they should actually write "do's and don't's" to make "don't" plural!

Stuck? Here's a hint!

If you decide to surround the variable with single quotes, then you need to put a backslash before every apostrophe inside the variable.