Skip to content

Commit 47d9c6d

Browse files
committed
gh-106318: Add examples for str.rfind() method
1 parent cea2d24 commit 47d9c6d

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
@@ -2408,6 +2408,16 @@ expression support in the :mod:`re` module).
24082408
Return the highest index in the string where substring *sub* is found, such
24092409
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
24102410
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2411+
For example:
2412+
2413+
.. doctest::
2414+
2415+
>>> 'spam, spam, spam'.rfind('sp')
2416+
12
2417+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2418+
6
2419+
2420+
See also :meth:`find` and :meth:`rindex`.
24112421

24122422

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

0 commit comments

Comments
 (0)