Skip to content

Commit 426683e

Browse files
[3.14] gh-106318: Add examples for str.rfind() method (GH-143582) (#143616)
gh-106318: Add examples for str.rfind() method (GH-143582) (cherry picked from commit c696f33) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent ae62d2b commit 426683e

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
@@ -2416,6 +2416,16 @@ expression support in the :mod:`re` module).
24162416
Return the highest index in the string where substring *sub* is found, such
24172417
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
24182418
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2419+
For example:
2420+
2421+
.. doctest::
2422+
2423+
>>> 'spam, spam, spam'.rfind('sp')
2424+
12
2425+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2426+
6
2427+
2428+
See also :meth:`find` and :meth:`rindex`.
24192429

24202430

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

0 commit comments

Comments
 (0)