gh-106318: Add example for str.swapcase() method (#144575)

This commit is contained in:
Adorilson Bezerra 2026-04-09 14:33:31 +01:00 committed by GitHub
parent ee2775cfae
commit d11e9ff8ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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()