From: Adorilson Bezerra Date: Thu, 9 Apr 2026 13:33:31 +0000 (+0100) Subject: gh-106318: Add example for str.swapcase() method (#144575) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d11e9ff8ca0e6fc5525a47eeb0e99637987bb385;p=thirdparty%2FPython%2Fcpython.git gh-106318: Add example for str.swapcase() method (#144575) --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a10551975edb..3d943566be34 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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()