Chapter 4: Escape Sequence as Normal Text

Method 1

 

print("Line A \\n Line B")

Output: Line A \n Line B

print("Tab A \\t Tab B")

Output: Tab A \t Tab B

print(" \\\' & \\\" ")

Output: \' & \"

 

Method 2 (Raw String)

 

Before the quotes, we can type normal text and prefix the string with an r inside the print function.

 

print(r"Line A \n Line B")

Output: Line A \n Line B

print(r"Tab A \t Tab B")

Output: Tab A \t Tab B

print(r" \' & \" ")

Output: \' & \"