Skip to content

Commit bc52457

Browse files
committed
gh-106318: Add example for str.swapcase() method
1 parent 6665115 commit bc52457

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
@@ -2792,8 +2792,22 @@ expression support in the :mod:`re` module).
27922792
.. method:: str.swapcase()
27932793

27942794
Return a copy of the string with uppercase characters converted to lowercase and
2795-
vice versa. Note that it is not necessarily true that
2796-
``s.swapcase().swapcase() == s``.
2795+
vice versa. For example:
2796+
2797+
.. doctest::
2798+
2799+
>>> 'Hello World'.swapcase()
2800+
'hELLO wORLD'
2801+
2802+
Note that it is not necessarily true that ``s.swapcase().swapcase() == s``.
2803+
For example:
2804+
2805+
.. doctest::
2806+
2807+
>>> 'straße'.swapcase().swapcase()
2808+
'strasse'
2809+
2810+
See also :meth:`str.lower` and :meth:`str.upper`.
27972811

27982812

27992813
.. method:: str.title()

0 commit comments

Comments
 (0)