From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 23 May 2025 09:50:17 +0000 (+0200) Subject: [3.13] gh-106318: Add example for `str.center()` (GH-134518) (#134572) X-Git-Tag: v3.13.4~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b203f511be80b9db7697606783ef2d3f3a4d92e;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-106318: Add example for `str.center()` (GH-134518) (#134572) Co-authored-by: Blaise Pabon --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ccaa0efaada7..a856047f2d6e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1652,8 +1652,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]])