How to pad with n characters in Python
With Python2.6 or better, there's no need to define your own function; the string format method can do all this for you:
In [18]: '{s:{c}^{n}}'.format(s='dog',n=5,c='x')
Out[18]: 'xdogx'
Using f-string: f'{"dog":x^5}'
yeah just use ljust or rjust to left-justify (pad right) and right-justify (pad left) with any given character.
For example ... to make '111' a 5 digit string padded with 'x'es
In Python3.6:
>>> '111'.ljust(5, 'x')
111xx
>>> '111'.rjust(5, 'x')
xx111