Skip to content

Commit f2dd414

Browse files
committed
gh-106318: Add examples for str.startwith() method
1 parent ccbe41e commit f2dd414

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,21 @@ expression support in the :mod:`re` module).
27352735
test string beginning at that position. With optional *end*, stop comparing
27362736
string at that position.
27372737

2738+
For example:
2739+
2740+
.. doctest::
2741+
2742+
>>> 'Python'.startswith('Py')
2743+
True
2744+
>>> 'a tuple of prefixes'.startswith(('at', 'in'))
2745+
False
2746+
>>> 'a tuple of prefixes'.startswith(('at', 'a'))
2747+
True
2748+
>>> 'Python is amazing'.startswith('is', 7)
2749+
True
2750+
2751+
See also :meth:`endswith` and :meth:`removeprefix`.
2752+
27382753

27392754
.. method:: str.strip(chars=None, /)
27402755

0 commit comments

Comments
 (0)