Python String center() method

The center() method will center align the string, using a specified character (space is default) as the fill character.

Syntax

Parameter

width This parameter represents the length of the returned string.

fillchar This parameter represents the character to fill the missing space on each side and the default value is ” ” (space).

Return

This method returns centered in a string of length width.

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This