March 2020
Beginner to intermediate
352 pages
8h 40m
English
A string already comes with the single (') and double ('') quotes incorporated within its syntax. Hence, if we need to print a single or a double quote within a string, it causes a SyntaxError. To avoid such an error, the quotes—whether they are single or double quotes—must be escaped. This phenomenon is called an escape sequence. An escape sequence begins with a backslash (\) and can be understood differently. If we intend to use a single quote or a double quote as a string, then it must be escaped by appending a backslash before it. Let's see it in action.
We will show the following example for all three cases (a single quote, a double quote, and a triple quote):
String = '''I'm a "Data Scientist"'''# Initial ...
Read now
Unlock full access