From adb278d35044d3d761b51bfac6f19c7d430b4e4f Mon Sep 17 00:00:00 2001 From: blaisep Date: Thu, 22 May 2025 12:44:54 -0400 Subject: [PATCH] gh-108316: Add example for `str.endswith()` WIP to fix #106318 using the contributions from https://github.com/python/cpython/pull/105670 --- Doc/library/stdtypes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 3486a18b5cb1f0..19dce9eeb4c15b 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1863,7 +1863,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:: The :meth:`~str.find` method should be used only if you need to know the