How is the syntax for a multi-line string different from a string that has two additional quotes inside of it?
In our Codecademy editor, strings and multi-line comments do share the same color: yellow. However! They’re not the same. When Python sees three quotation marks (single
’ or double
”) before and after something, it knows to make that a comment, rather than run it as code, if it’s not preceded by assignment to a variable. To illustrate this point, take a look at the example below:
long_string = """ This is just a long string assigned to the long_string variable! useful for paragraphs or lines that are very long """ """ This is a multi-line comment. It spands multiple lines! It has no variable before it that it is being assigned to, so it is not a string like above. """