Skip to content

Commit 8337805

Browse files
[3.13] gh-106318: Add example for str.swapcase() method (GH-144575) (#148297)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 0438467 commit 8337805

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

26222622
Return a copy of the string with uppercase characters converted to lowercase and
2623-
vice versa. Note that it is not necessarily true that
2624-
``s.swapcase().swapcase() == s``.
2623+
vice versa. For example:
2624+
2625+
.. doctest::
2626+
2627+
>>> 'Hello World'.swapcase()
2628+
'hELLO wORLD'
2629+
2630+
Note that it is not necessarily true that ``s.swapcase().swapcase() == s``.
2631+
For example:
2632+
2633+
.. doctest::
2634+
2635+
>>> 'straße'.swapcase().swapcase()
2636+
'strasse'
2637+
2638+
See also :meth:`str.lower` and :meth:`str.upper`.
26252639

26262640

26272641
.. method:: str.title()

0 commit comments

Comments
 (0)