Skip to content

Commit 1b6d737

Browse files
pythongh-106318: Add examples for str.startswith() method (python#144369)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 914fbec commit 1b6d737

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,19 @@ expression support in the :mod:`re` module).
27512751
test string beginning at that position. With optional *end*, stop comparing
27522752
string at that position.
27532753

2754+
For example:
2755+
2756+
.. doctest::
2757+
2758+
>>> 'Python'.startswith('Py')
2759+
True
2760+
>>> 'a tuple of prefixes'.startswith(('at', 'a'))
2761+
True
2762+
>>> 'Python is amazing'.startswith('is', 7)
2763+
True
2764+
2765+
See also :meth:`endswith` and :meth:`removeprefix`.
2766+
27542767

27552768
.. method:: str.strip(chars=None, /)
27562769

0 commit comments

Comments
 (0)