Skip to content

Commit 3c9c3d3

Browse files
authored
gh-106318: Add examples for str.rpartition() method (#143891)
1 parent 375e372 commit 3c9c3d3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,19 @@ expression support in the :mod:`re` module).
25622562
after the separator. If the separator is not found, return a 3-tuple containing
25632563
two empty strings, followed by the string itself.
25642564

2565+
For example:
2566+
2567+
.. doctest::
2568+
2569+
>>> 'Monty Python'.rpartition(' ')
2570+
('Monty', ' ', 'Python')
2571+
>>> "Monty Python's Flying Circus".rpartition(' ')
2572+
("Monty Python's Flying", ' ', 'Circus')
2573+
>>> 'Monty Python'.rpartition('-')
2574+
('', '', 'Monty Python')
2575+
2576+
See also :meth:`partition`.
2577+
25652578

25662579
.. method:: str.rsplit(sep=None, maxsplit=-1)
25672580

0 commit comments

Comments
 (0)