Function Of Backslash In Python

Share:

 Functions Of Backslash /:



What Is Backslash In Python?

In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters

 Backslash Functions:

\n  = to make a newline

for example:

print("My Name Is Najwa.\n I am From Pakistan ")

output:

My Name Is Najwa
I am From Pakistan

\t   = to make a tab(space)

for example:

print("My Name Is Najwa.\t I am From Pakistan") 

output:

My Name Is Najwa.     I am From Pakistan

\r   = to  carriage return

for example:

print("\t programming \r python")

output:

python programming

\    = to print as it is

for example:

print("\"python programming\"")

output:


"python programming"