Skip to content

Commit 65acd01

Browse files
miss-islingtonadorilsonStanFromIreland
authored
[3.13] gh-106318: Add examples for str.startswith() method (GH-144369) (#144480)
gh-106318: Add examples for `str.startswith()` method (GH-144369) (cherry picked from commit 1b6d737) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 7f39393 commit 65acd01

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
@@ -2510,6 +2510,19 @@ expression support in the :mod:`re` module).
25102510
test string beginning at that position. With optional *end*, stop comparing
25112511
string at that position.
25122512

2513+
For example:
2514+
2515+
.. doctest::
2516+
2517+
>>> 'Python'.startswith('Py')
2518+
True
2519+
>>> 'a tuple of prefixes'.startswith(('at', 'a'))
2520+
True
2521+
>>> 'Python is amazing'.startswith('is', 7)
2522+
True
2523+
2524+
See also :meth:`endswith` and :meth:`removeprefix`.
2525+
25132526

25142527
.. method:: str.strip(chars=None, /)
25152528

0 commit comments

Comments
 (0)