String literals inside triple quotes can span multiple lines of text. Because Python otherwise interprets whitespace (code indentation) as valid parts of code, this is helpful to be able to easily write multiple lines of some string.
So one set of quotations is to specify this being a string (sentence, for the lack of a better word?). The second set of quotations is to specify that we pressed the “return” key on our computer to get to the next line. And the third set of quotations is to specify that we pressed the “return” key yet again on our computer to get to the line below?
I don’t think so. I think that the three quotations just lets us write a long string on multiple lines of text and tell the Python compiler that this is all one string.
I think when you use a single quotation set, it establishes a string. But because Python interprets whitespace, you have to use a set of three quotation marks to establish a string along multiple lines of text.
…
In plain English: Both types of literals can be enclosed in matching single quotes (' ) or double quotes (" ). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings ). The backslash (\ ) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character.
…
In triple-quoted literals, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the literal. (A “quote” is the character used to open the literal, i.e. either ' or " .)
…