Closed pjhinton closed 4 years ago
There are a couple of instances in Chapter 3 where string formatting is done with the percent infix operator rather than str.format().
str.format()
The first is in the subsection Lining Things Up:
'{:{width}}' % ("Monty Python", width=15)
which can be expressed as:
'{:{width}}'.format('Monty Python', width=15)
and in the subsection Text Wrapping
pieces = [format % (word, len(word)) for word in saying]
template = '{} {}' pieces = [template.format(word, len(word)) for word in saying]
There are a couple of instances in Chapter 3 where string formatting is done with the percent infix operator rather than
str.format()
.The first is in the subsection Lining Things Up:
which can be expressed as:
and in the subsection Text Wrapping
which can be expressed as: