First convert all of the header including '.'
to a string so you can calculate the width including it.
>>> '{:<20} sum so far: {}.'.format('{}.'.format(9), 123)
'9. sum so far: 123.'
>>> '{:<20} sum so far: {}.'.format('{}.'.format(10), 123)
'10. sum so far: 123.'
source
to share