From: Blaise Pabon Date: Wed, 27 Aug 2025 06:42:00 +0000 (-0400) Subject: gh-106318: Add example for `str.find()` (#134529) X-Git-Tag: v3.15.0a1~583 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14a5ad1db177c557f2c433501d591d576954a0ae;p=thirdparty%2FPython%2Fcpython.git gh-106318: Add example for `str.find()` (#134529) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 56a9b6b9aff6..3320f7c3bba7 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1911,6 +1911,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::