Python‎ > ‎str‎ > ‎

str.center()

http://www.adilwaseem.com/

Definition
Return  with the string after filling the character in position provided.

Syntax
x.center(width[, fillchar]) -> str

Parameters
  • x=string
  • width=numeric value
  • fillchar=string
  • The fill character must be exactly one character long
Examples
The method returns with the filling the character in center provided.
 >>> "Python Research Centre".center(44,'o')
'oooooooooooPython Research Centreooooooooooo'
>>> "Python Research Centre".center(44,'p')
'pppppppppppPython Research Centreppppppppppp'
>>> "Python Research Centre".center(23,'a')
'aPython Research Centre'
>>> 

Comments