]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add example for str.swapcase() method (GH-144575) (#148297)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 9 Apr 2026 13:40:28 +0000 (15:40 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 13:40:28 +0000 (13:40 +0000)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Doc/library/stdtypes.rst

index 95d281811bedc8d5c4151c39392c772015fb241d..13275dc760f815693a6b38a94b79b81f258d88da 100644 (file)
@@ -2620,8 +2620,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()