More on Formatting Output¶
In python 3, print is a function call. The general form of its syntax is print(<expr> [, <expr>]*)
. The square brackets indicate 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 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)
.