Detailed Print – CSKC
Sign In

Search

siteicon
Code Learning#PYTHON#8197 Back

printing quotes slash

Printing characters that are used to form strings like single quote, double quote require special technique of preceding it with backslash character. Same applies for backslash \ itself.

Source Code

		 

Click to open popup

Run Output

"Python" is great
'Python' is great
'Python' is great
"Python" is great
Backslash \

Notes

  • This is a very old technique evolved from the days of C language to fit characters into a string that are otherwise not feasible.
  • Preceding a character with backslash (\) for special characters within a string literal is called escaping and the particular character with \ is called escape sequence.
  • Some more escape sequences we shall learn in subsequent examples here.