Prints - multiline

Sometimes we have a lot to say. If we try and fit it all in one print statement, it may be hard to read (in the code atleast). So lets cover how to make multi-line print statements easier to read.

The first thing we can do is separate formation of the string to above the print and store in a variable, then simply print this variable.

In a similar manner to how we concatted strings earlier, we can use a backslash to indicate the line continues onto the next line.

There are also triple quotes we can use, either single or double quotation marks. Just like with regular strings in Python, there is essentially no difference. Notice how in the following example single quotes display without any issue. Double quotes will as well.

The one drawback with triple quotes is needing to write characters up against the left side of the editor to prevent extra spacing.

The triple double-quote is often used to write docstrings. These are very helpful to explain the purpose of a function. This is a very good habit to start, writing docstrings as well as comments throughout our code helps both others understand the purpose of it as well as ourselves one plus years later.