Skip to content

Commit c2f19ad

Browse files
Describing negative step in slicing.
1 parent 68aa560 commit c2f19ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/reference/datamodel.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ sequence of the same type. The comment above about negative indexes also applies
321321
to negative slice positions.
322322

323323
Some sequences also support "extended slicing" with a third *step* parameter:
324-
``a[start:stop:step]`` selects all items of *a* with index *i* where
325-
``i = start + n*step``, ``n >= 0`` and ``start <= i < stop``.
324+
``a[start:stop:step]`` selects all items of *a* with index *i*, where
325+
``i = start + n*step`` and ``0 <= n``, such that ``start <= i < stop`` for
326+
``0 <= step``, and ``stop < i <= start`` for ``step < 0``.
326327

327328
Sequences are distinguished according to their mutability:
328329

0 commit comments

Comments
 (0)