From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 9 Apr 2026 13:39:39 +0000 (+0200) Subject: [3.14] gh-106318: Add example for str.swapcase() method (GH-144575) (#148296) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=571c337a5dd80e4dabc8fe0e92003d77b583665d;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-106318: Add example for str.swapcase() method (GH-144575) (#148296) Co-authored-by: Adorilson Bezerra --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index be1ef1a1d1c6..37b940a07e6c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2771,8 +2771,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()