August 2019
Beginner
482 pages
12h 56m
English
Strings represent text of any kind. As Python needs to distinguish between code (what it should execute) and strings (data), strings have to be wrapped with quotes: single quotes, double quotes, or triple single quotation marks. This last option can be used with multiline text, while the first two options will only work on the same line. Let's see some examples. Here is a string that is surrounded by single quotes. In this case, you can use double quotes within your text string, and this won't break the parsing mechanism:
text1 = ‘This is a so-called “speakeasy”'
Here is a similar example with double quotes. In this case, we can use single quotes in the text without breaking the code:
text2 = “This is Sam's Tavern”
Finally, triple ...
Read now
Unlock full access