]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add example for `str.center()` (GH-134518) (#134572)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 23 May 2025 09:50:17 +0000 (11:50 +0200)
committerGitHub <noreply@github.com>
Fri, 23 May 2025 09:50:17 +0000 (09:50 +0000)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Doc/library/stdtypes.rst

index ccaa0efaada7c70deac650832c4d7fd24ada4faa..a856047f2d6e8262e70ea8519c8dd32c4bb3dae0 100644 (file)
@@ -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]])