Skip to content

Commit 39e0667

Browse files
adorilsonmiss-islington
authored andcommitted
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 a4a33ff commit 39e0667

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
@@ -2270,6 +2270,16 @@ expression support in the :mod:`re` module).
22702270
Return the highest index in the string where substring *sub* is found, such
22712271
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
22722272
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2273+
For example:
2274+
2275+
.. doctest::
2276+
2277+
>>> 'spam, spam, spam'.rfind('sp')
2278+
12
2279+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2280+
6
2281+
2282+
See also :meth:`find` and :meth:`rindex`.
22732283

22742284

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

0 commit comments

Comments
 (0)