Game Development Reference
In-Depth Information
5 - Jokes
He flew away in a green eal helicopter.
This is because the "t" in "teal" was seen as an escape character since it came after a
backslash. The escape character t simulates pushing the Tab key on your keyboard. Escape
characters are there so that strings can have characters that cannot be typed in.
Instead, try this line:
>>> print('He flew away in a green\\teal
helicopter.')
Here is a list of escape characters in Python:
Table 5-1: Escape Characters
Escape Character What Is Actually Printed
\\
Backslash (\)
\'
Single quote (')
\"
Double quote (")
\n
Newline
\t
Tab
Quotes and Double Quotes
Strings don't always have to be in between single quotes in Python. You can also put
them in between double quotes. These two lines print the same thing:
>>> print('Hello world')
Hello world
>>> print("Hello world")
Hello world
But you cannot mix quotes. This line will give you an error if you try to use them:
>>> print('Hello world")
SyntaxError: EOL while scanning single-quoted
string
>>>
Search WWH ::




Custom Search