Python Escape Sequence

Escape Sequence In Python

What is escape sequence?

A escape sequence is a special character followed by a back-slash ( \ ). It allow to include a illegal character in a string, for example if you insert single-quote inside a string surrounded by single-quote then It shows an error (shown below).



To remove this error, use backslash ( \ ) before every single-quote.


Useful escape sequence in python :

  •  \'  : Used to insert a single-quote inside a string.
  •  \"  : Used to insert a double-quote.
  •  \\  : Used to insert a backslash.
  •  \n  : Used to insert a new-line.
  •  \t  : Used to insert a horizontal-tab.
  •  \v  : Used to insert a vertical-tab.
  •  \b  : Used to insert a backspace.



Try to write a letter using python escape sequence.

Comments