Learn Python 3 the Hard Way: A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code
by Zed A. Shaw
Exercise 10. What Was That?
In Exercise 9 I threw you some new stuff, just to keep you on your toes. I showed you two ways to make a string that goes across multiple lines. In the first way, I put the characters \n (backslash n) between the names of the months. These two characters put a new line character into the string at that point.
This \ (backslash) character encodes difficult-to-type characters into a string. There are various escape sequences available for different characters you might want to use. We’ll try a few of these sequences so you can see what I mean.
An important escape sequence is to escape a single-quote (') or double-quote ("). Imagine you have a string that uses double-quotes and you want to put a double-quote inside the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access