]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add examples for str.rfind() method (#143582)
authorAdorilson Bezerra <adorilson@gmail.com>
Fri, 9 Jan 2026 15:24:31 +0000 (15:24 +0000)
committerGitHub <noreply@github.com>
Fri, 9 Jan 2026 15:24:31 +0000 (16:24 +0100)
Doc/library/stdtypes.rst

index 3d347a59717bce1dccc0d43a5a288ce077ae0ad0..6118d7c556a617d9c78e4f67af13691731025c5f 100644 (file)
@@ -2424,6 +2424,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]])