How to pad a string to a fixed length with spaces in Python? January 19, 2023 by Tarik This is super simple with format: >>> a = "John" >>> "{:<15}".format(a) 'John '