From 2e2434753dcdbcefa6e7f9037f1b83fe7f873bcd Mon Sep 17 00:00:00 2001 From: Blaise Pabon Date: Wed, 27 Aug 2025 02:42:00 -0400 Subject: [PATCH] gh-106318: Add example for `str.find()` (GH-134529) (cherry picked from commit 14a5ad1db177c557f2c433501d591d576954a0ae) Co-authored-by: Blaise Pabon Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/library/stdtypes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 7ad073a6edc9a4..7c81e77f5b21e9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1775,6 +1775,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::