Skip to content

Commit 571c337

Browse files
[3.14] gh-106318: Add example for str.swapcase() method (GH-144575) (#148296)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 88fc1e6 commit 571c337

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

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

27772791

27782792
.. method:: str.title()

0 commit comments

Comments
 (0)