Skip to content

Commit 7618482

Browse files
[3.13] gh-106318: Add examples for str.rfind() method (GH-143582) (#143617)
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 bf7990c commit 7618482

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
@@ -2278,6 +2278,16 @@ expression support in the :mod:`re` module).
22782278
Return the highest index in the string where substring *sub* is found, such
22792279
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
22802280
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2281+
For example:
2282+
2283+
.. doctest::
2284+
2285+
>>> 'spam, spam, spam'.rfind('sp')
2286+
12
2287+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2288+
6
2289+
2290+
See also :meth:`find` and :meth:`rindex`.
22812291

22822292

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

0 commit comments

Comments
 (0)