center() - Returns a centered string

Centers a string to fit in the specified with with an optional fill character.  If the string is longer than the specified width, the string is returned without being centered.

Example

Python
print('abc'.center(12))
print('abc'.center(12, '-'))
print('This string is longer than 12 characters.'.center(12, '='))

Output

    abc
----abc-----
This string is longer than 12 characters.