Python - string center() method


Python tip:

You can use .center() to create a centered string of given width.

string.center(width, fillchar)

Padding on each side is a space, " ", by default.

print("Mike".center(10, "*"))
# => ***Mike***