Skip to content

Commit 409a9a0

Browse files
committed
Add example for str.endswith()
WIP to fix python#106318 using the contributions from python#105670
1 parent 09e72cf commit 409a9a0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Doc/library/stdtypes.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,19 @@ expression support in the :mod:`re` module).
18341834
Return ``True`` if the string ends with the specified *suffix*, otherwise return
18351835
``False``. *suffix* can also be a tuple of suffixes to look for. With optional
18361836
*start*, test beginning at that position. With optional *end*, stop comparing
1837-
at that position.
1837+
at that position. Use the *start* and *end* is equivalent to
1838+
``str[start:end].endswith(suffix)``. For example::
1839+
1840+
>>> 'Python'.endswith('on')
1841+
True
1842+
>>> 'a tuple of suffixes'.endswith(('at', 'in'))
1843+
False
1844+
>>> 'a tuple of suffixes'.endswith(('at', 'es'))
1845+
True
1846+
>>> 'Python is amazing'.endswith('is', 0, 9)
1847+
True
1848+
1849+
See also :meth:`startswith` and :meth:`removesuffix`.
18381850

18391851

18401852
.. method:: str.expandtabs(tabsize=8)

0 commit comments

Comments
 (0)