]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add example for str.swapcase() method (#144575)
authorAdorilson Bezerra <adorilson@gmail.com>
Thu, 9 Apr 2026 13:33:31 +0000 (14:33 +0100)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 13:33:31 +0000 (16:33 +0300)
Doc/library/stdtypes.rst

index a10551975edb731352a0da52e754b4eb3f4ab8f0..3d943566be34ff17d4add7e252cc927fad199875 100644 (file)
@@ -2775,8 +2775,22 @@ expression support in the :mod:`re` module).
 .. method:: str.swapcase()
 
    Return a copy of the string with uppercase characters converted to lowercase and
-   vice versa. Note that it is not necessarily true that
-   ``s.swapcase().swapcase() == s``.
+   vice versa. For example:
+
+   .. doctest::
+
+      >>> 'Hello World'.swapcase()
+      'hELLO wORLD'
+
+   Note that it is not necessarily true that ``s.swapcase().swapcase() == s``.
+   For example:
+
+   .. doctest::
+
+      >>> 'straße'.swapcase().swapcase()
+      'strasse'
+
+   See also :meth:`str.lower` and :meth:`str.upper`.
 
 
 .. method:: str.title()