From 47d9c6d845ba3073210aba84046634a97b63ca5f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 8 Jan 2026 20:18:28 +0000 Subject: [PATCH] gh-106318: Add examples for str.rfind() method --- Doc/library/stdtypes.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ae197f765d1e16..0b370443399a48 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2408,6 +2408,16 @@ expression support in the :mod:`re` module). Return the highest index in the string where substring *sub* is found, such that *sub* is contained within ``s[start:end]``. Optional arguments *start* and *end* are interpreted as in slice notation. Return ``-1`` on failure. + For example: + + .. doctest:: + + >>> 'spam, spam, spam'.rfind('sp') + 12 + >>> 'spam, spam, spam'.rfind('sp', 0, 10) + 6 + + See also :meth:`find` and :meth:`rindex`. .. method:: str.rindex(sub[, start[, end]])