Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fa6374

Browse files
committed
Issue #1446619: Merge slicing description from 3.6
2 parents 9e40afe + 0efb5b3 commit 9fa6374

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,10 @@ Notes:
942942
The slice of *s* from *i* to *j* with step *k* is defined as the sequence of
943943
items with index ``x = i + n*k`` such that ``0 <= n < (j-i)/k``. In other words,
944944
the indices are ``i``, ``i+k``, ``i+2*k``, ``i+3*k`` and so on, stopping when
945-
*j* is reached (but never including *j*). If *i* or *j* is greater than
946-
``len(s)``, use ``len(s)``. If *i* or *j* are omitted or ``None``, they become
945+
*j* is reached (but never including *j*). When *k* is positive,
946+
*i* and *j* are reduced to ``len(s)`` if they are greater.
947+
When *k* is negative, *i* and *j* are reduced to ``len(s) - 1`` if
948+
they are greater. If *i* or *j* are omitted or ``None``, they become
947949
"end" values (which end depends on the sign of *k*). Note, *k* cannot be zero.
948950
If *k* is ``None``, it is treated like ``1``.
949951

0 commit comments

Comments
 (0)