More on Formatting OutputΒΆ

In python 2.7, print is a special statement, not a function call. The general form of its syntax is print <expr> [, <expr>]*. The square brackets indicates that it’s optional to have additional expressions. The * means that you can have 0 or more of them. If <expr> evaluates to a single value, then the printed representation of that value is output.

If there are several expressions, then the printed representation of each one is output, with spaces separating them.

If there is a trailing comma, then a space is output at the end rather than a newline.

If there is just one expression and it is in parentheses, it has the same effect as not including the parentheses.

If there are multiple values, separated by commas, enclosed in parentheses, it is treated as a single tuple. For example, print (3, 5) outputs the printed representation, which is (3, 5).

Next Section - String Interpolation