Python String Center() Method
Python center() method alligns string to the center by filling paddings left and right of the string. This method takes two parameters, first is a width and second is a fillchar which is optional. The fillchar is a character which is used to fill left and right padding of the string.
It returns modified string.
Python String Center() Method Example 1:default fill char
Here, we did not pass second parameter. By default it takes spaces.
Old value: Hello Javatpoint New value: Hello Javatpoint
Python String Center() Method Example 2
Here, we are providing padding char (optional) parameter as #. See the example.
Old value: Hello Javatpoint New value: ##Hello Javatpoint##
Python String Center() Method Example 3
Old value: Hello Javatpoint New value: !!Hello Javatpoint!!
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week