Skip to content

Commit 8661e67

Browse files
committed
gh-106318: Add example for str.rindex() method
1 parent c461aa9 commit 8661e67

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,18 @@ expression support in the :mod:`re` module).
25462546

25472547
Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not
25482548
found.
2549+
For example:
2550+
2551+
.. doctest::
2552+
2553+
>>> 'spam, spam, spam'.rindex('eggs')
2554+
Traceback (most recent call last):
2555+
File "<stdin-0>", line 1, in <module>
2556+
'spam, spam, spam'.rindex('eggs')
2557+
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2558+
ValueError: substring not found
2559+
2560+
See also :meth:`index` and :meth:`find`.
25492561

25502562

25512563
.. method:: str.rjust(width, fillchar=' ', /)

0 commit comments

Comments
 (0)