Escape sequence in python

 Sequence of character after backslash ‘\’ are called escape sequence character.

Escape sequence character comprises of more than on character but represent one character when used within the string.

Some of the commonly used escape sequence characters are :-

‘\\’Backslash character
‘\”single quote character
‘\n’Newline character
‘\t’Tab character

Example :-

# for backslash 
print("This is a\\ string")
 
# for single quote in string
print("This is \'a\' string")
 
#for tab 
print("This is a\t string")
 
# for line break
print("This is a\n string")
Python

Output :-

This is a\ string   
This is 'a' string                                                                                                                            
This is a        string                                                                                                                       
This is a                                                                                                                                     
 string 
Markup

These are the most commonly used escape sequence characters. I hope you understand this tutorial. If you have query or suggestion please do a comment.

Thank You.

No comments:

Post a Comment

Featured Post

List in Python

  List are just like dynamic array, declared in other languages( like vector in c++ and array list in java ). A single list may contain data...