Skip to content

Commit c696f33

Browse files
authored
gh-106318: Add examples for str.rfind() method (#143582)
1 parent 6d6c7ed commit c696f33

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,16 @@ expression support in the :mod:`re` module).
24242424
Return the highest index in the string where substring *sub* is found, such
24252425
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
24262426
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2427+
For example:
2428+
2429+
.. doctest::
2430+
2431+
>>> 'spam, spam, spam'.rfind('sp')
2432+
12
2433+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2434+
6
2435+
2436+
See also :meth:`find` and :meth:`rindex`.
24272437

24282438

24292439
.. method:: str.rindex(sub[, start[, end]])

0 commit comments

Comments
 (0)