1.1.3 - Printing Multiple Items

A print statement can output multiple things at once, each item separated by a comma. For example this code will print out : Your new score is 1040

>>> print("Your new score is", 1030 + 10)

The next line of code will print out "Your new score is 1030+10". The numbers are not added together because they are inside the quotes. Anything inside quotes, the computer treats it as text. Anything outside quotes the computer thinks it is a mathematical statement or computer code.

>>> print("Your new score is", "1030 + 10")

This next code example doesn't work at all. This is because there is no comma separating the text between the quotes, and the 1030+10. At first, it may appear that there is a comma, but the comma is inside the quotes. The comma that separates the terms to be printed must be outside the quotes. If the programmer wants a comma to be printed, then it must be inside the quotes:

>>> print("Your new score is," 1030 + 10)

This next example does work, because there is a comma separating the terms. It prints: 

Your new score is, 1040

Note that only one comma prints out. Commas outside the quotes separate terms, commas inside the quotes are printed. The first comma is printed, the second is used to separate terms.

>>> print("Your new score is,", 1030 + 10)

Now try and think. When a comma goes outside the parenthesis and when not. When you should put a comma and when you shouldn't?