From: Blaise Pabon Date: Fri, 23 May 2025 09:44:15 +0000 (-0400) Subject: gh-106318: Add example for `str.center()` (#134518) X-Git-Tag: v3.15.0a1~1553 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da9b5c1c9c6ecea399b26175a2d048051d21aa04;p=thirdparty%2FPython%2Fcpython.git gh-106318: Add example for `str.center()` (#134518) --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 3486a18b5cb1..ce6134768541 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1788,8 +1788,14 @@ expression support in the :mod:`re` module). Return centered in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is - returned if *width* is less than or equal to ``len(s)``. - + returned if *width* is less than or equal to ``len(s)``. For example:: + + >>> 'Python'.center(10) + ' Python ' + >>> 'Python'.center(10, '-') + '--Python--' + >>> 'Python'.center(4) + 'Python' .. method:: str.count(sub[, start[, end]])