]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add examples for str.rfind() method (GH-143582) (#143617)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 9 Jan 2026 15:30:23 +0000 (16:30 +0100)
committerGitHub <noreply@github.com>
Fri, 9 Jan 2026 15:30:23 +0000 (15:30 +0000)
gh-106318: Add examples for str.rfind() method (GH-143582)
(cherry picked from commit c696f33d9ee425d7acd5de90d5418a3280444962)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Doc/library/stdtypes.rst

index 527717b8deb31c0d2ac2fd1381634d585170a8d7..438b07f22366e13bf743ed7e113fe871112cf729 100644 (file)
@@ -2278,6 +2278,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]])