Skip to content

Commit adb278d

Browse files
committed
pythongh-108316: Add example for str.endswith()
WIP to fix python#106318 using the contributions from python#105670
1 parent 09e72cf commit adb278d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,14 @@ expression support in the :mod:`re` module).
18631863
Return the lowest index in the string where substring *sub* is found within
18641864
the slice ``s[start:end]``. Optional arguments *start* and *end* are
18651865
interpreted as in slice notation. Return ``-1`` if *sub* is not found.
1866+
For example::
1867+
1868+
>>> 'spam, spam, spam'.find('sp')
1869+
0
1870+
>>> 'spam, spam, spam'.find('sp', 5)
1871+
6
18661872

1873+
See also :meth:`rfind` and :meth:`index`.
18671874
.. note::
18681875

18691876
The :meth:`~str.find` method should be used only if you need to know the

0 commit comments

Comments
 (0)