Python String center() is an inbuilt method that creates and returns a new string that is padded with the specified character. The string center() method in python is used to provide padding with a specific character, which can be space or any other character. The method returns a new string that is padded.

Python String center()

The syntax of the center() method is the following.

string.center(width, fillchar)

The center() method takes two arguments:

width: length of the  string with padded characters.

fillchar: padding character.

The fillchar argument is optional. If it’s not provided, space is taken as a default argument.

#python #python string center

Python String Center: How to Use center() Method Example
2.00 GEEK