How to pad a string to a fixed length with spaces [duplicate]

This is super simple with format:

>>> a = "John"
>>> "{:<15}".format(a)
'John           '

Leave a Comment