Print Formatting in Python

In Python, you’ll often want to print your variables in a nice way, along with some fixed text.  For instance, if you have two variables,

and

you might want to print a sentence that uses both variables.  There are many ways to do this in Python, but here you’ll learn the best one.

The ‘f’ before the first quote is not a typo!  The ‘f’ stands for format, and if you leave it out the variable values won’t get substituted for {item1} and {item2}.

We’ll come back to string formatting when we study numbers and Python.

Note:  If you’re using an old version of Python (before v. 3.6) you’ll need to use a different method to format strings with variables.  The best solution is to update Python!