How to pad a string to a fixed length with spaces [duplicate] June 27, 2023 by Tarik This is super simple with format: >>> a = "John" >>> "{:<15}".format(a) 'John '