8000 introduce omitted index default before using it (GH-27775) · python/cpython@599f5c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 599f5c8

Browse files
introduce omitted index default before using it (GH-27775)
1 parent b1930bf commit 599f5c8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Doc/tutorial/introduction.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,6 @@ to obtain individual characters, *slicing* allows you to obtain substring::
269269
>>> word[2:5] # characters from position 2 (included) to 5 (excluded)
270270
'tho'
271271

272-
Note how the start is always included, and the end always excluded. This
273-
makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::
274-
275-
>>> word[:2] + word[2:]
276-
'Python'
277-
>>> word[:4] + word[4:]
278-
'Python'
279-
280272
Slice indices have useful defaults; an omitted first index defaults to zero, an
281273
omitted second index defaults to the size of the string being sliced. ::
282274

@@ -287,6 +279,14 @@ omitted second index defaults to the size of the string being sliced. ::
287279
>>> word[-2:] # characters from the second-last (included) to the end
288280
'on'
289281

282+
Note how the start is always included, and the end always excluded. This
283+
makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::
284+
285+
>>> word[:2] + word[2:]
286+
'Python'
287+
>>> word[:4] + word[4:]
288+
'Python'
289+
290290
One way to remember how slices work is to think of the indices as pointing
291291
*between* characters, with the left edge of the first character numbered 0.
292292
Then the right edge of the last character of a string of *n* characters has

0 commit comments

Comments
 (0)
0