This Escape Characters lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.
A backslash marks a character that is hard to type. \n starts a new line. \" is a quote inside a double-quoted string. \\ is one backslash.
A raw string starts with r. Backslashes in it stay as backslashes, which is what a regular expression usually wants.
Example 1: Start here
A raw string cannot end with a single backslash.
print("Line one\nLine two") # print writes this; the quotes are not shown
print("She said \"hello\"")
Example 2: A quote inside text
A backslash lets the quote stay inside the string.
print("She said \"hello\"") # print writes this; the quotes are not shown
Example 3: A real new line
\n is one character that starts a new line.
print("Line one\nLine two") # print writes this; the quotes are not shown
Example 4: A tab
\t inserts a tab between the two words.
print("Name\tAsha") # print writes this; the quotes are not shown
