description
Python center () Returns a string of the original center, and padded with spaces to the width of the length of the new string. The default pad character is a space.
grammar
center () method syntax:
str.center(width[, fillchar])
parameter
- width - The total width of the string.
- fillchar - filled characters.
return value
This method returns a string of the original center, and padded with spaces to the width of the length of the new string.
Examples
The following example shows the center () instance method:
>>>str = 'runoob'
>>> str.center(20, '*')
" ******* ******* runoob '
>>> str.center(20)
' Runoob '
>>>