Skip to content

Commit d11e9ff

Browse files
authored
gh-106318: Add example for str.swapcase() method (#144575)
1 parent ee2775c commit d11e9ff

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Doc/library/stdtypes.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,8 +2775,22 @@ expression support in the :mod:`re` module).
27752775
.. method:: str.swapcase()
27762776

27772777
Return a copy of the string with uppercase characters converted to lowercase and
2778-
vice versa. Note that it is not necessarily true that
2779-
``s.swapcase().swapcase() == s``.
2778+
vice versa. For example:
2779+
2780+
.. doctest::
2781+
2782+
>>> 'Hello World'.swapcase()
2783+
'hELLO wORLD'
2784+
2785+
Note that it is not necessarily true that ``s.swapcase().swapcase() == s``.
2786+
For example:
2787+
2788+
.. doctest::
2789+
2790+
>>> 'straße'.swapcase().swapcase()
2791+
'strasse'
2792+
2793+
See also :meth:`str.lower` and :meth:`str.upper`.
27802794

27812795

27822796
.. method:: str.title()

0 commit comments

Comments
 (0)