format
dealing with stuff such as print('a={0:5} b={1:7}'.format(a,b)
In Python 3, we can format the way output appears using the format
method of string
objects.
Those statements look like this:
print('a={:5} b={:7}'.format(a,b))
To understand what this will print, you can consult any of the following resources:
- Chapter 4, pages 100-105 in the Perkovic 2nd Edition Textbook.
- This tutorial from digitalocean on string formatters in Python3
- The pyformat.info/ web page, which compares the old and new styles of formatting in Python.