]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-106318: Add example for `str.find()` (GH-134529) (#138174)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Aug 2025 06:48:49 +0000 (08:48 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Aug 2025 06:48:49 +0000 (06:48 +0000)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Doc/library/stdtypes.rst

index a81a6704142dcc87cd753c9c1c7a7a0a3b4d25bc..027306b80533aff0a1f616d3ec83cc520ec00a48 100644 (file)
@@ -1909,6 +1909,14 @@ expression support in the :mod:`re` module).
    Return the lowest index in the string where substring *sub* is found within
    the slice ``s[start:end]``.  Optional arguments *start* and *end* are
    interpreted as in slice notation.  Return ``-1`` if *sub* is not found.
+   For example::
+
+      >>> 'spam, spam, spam'.find('sp')
+      0
+      >>> 'spam, spam, spam'.find('sp', 5)
+      6
+
+   See also :meth:`rfind` and :meth:`index`.
 
    .. note::