Python allows for certain characters such as a Tab or Carriage Return to be embedded within strings to allow extra control over printing. There are also times that you have a string that requires a single or double quote that would normally cause problems.
For example, let’s say you decided to create a string using the single quote as the string delimiter. Without using an escape sequence you can’t have a single quote within the string. While you could use double quotes to delimit the string, that might be an issue.
>>> test = ‘This is a test of the \’ (single quote) character’
“This is a test of the ‘ (single quote) character”
The escape sequence starts with a backslash (\) character then followed by a character. This will be interpreted by Python as a special character.
More details about escape sequences can be found here