Python Escape Characters & Sequences - chrisbitm/python GitHub Wiki

Escape characters are special sequences that begin with a backslash () and allow you to include characters in a string that are otherwise hard to type or have special meaning (like a newline or a tab). These characters go inside a print statement and must be within quotation marks as well.

Below is not a complete list, but some of the popular ones are as follows.

\n

Meaning: New Line or Line-feed.

Below Code:

print("Hello")
print("World")

Is the same as this.

print("Hello\nWorld")

\t

Meaning: Horizontal Tab (4 spaces); same functionality as pressing Tab key on Keyboard

print("Game\tIs\tNot\tOver")

\a

Meaning: Sounds System Bell (If applicable)

print("\a")