To include multiple pieces of data in a string, you use multiple formatting codes and pass the arguments in a tuple (that is, inside parentheses, with the values separated by commas; see Chapters 3 and 8 for a refresher on tuples).
This section works with line 4 of the following code, which calculates and prints a table of powers:
print "%2s %5s %12s" % ('x', 'x**2', 'x**x')
To insert multiple data items into a string, follow these steps:
Was this article helpful?