File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -299,14 +299,17 @@ Sequences
299299These represent finite ordered sets indexed by non-negative numbers. The
300300built-in function :func: `len ` returns the number of items of a sequence. When
301301the length of a sequence is *n *, the index set contains the numbers 0, 1,
302- ..., *n *-1. Item *i * of sequence *a * is selected by ``a[i] ``.
302+ ..., *n *-1. Item *i * of sequence *a * is selected by ``a[i] ``. Some sequences,
303+ including built-in sequences, interpret negative subscripts by adding the
304+ sequence length. For example, ``a[-2] `` equals ``a[n-2] ``, the second to last
305+ item of sequence a with length ``n ``.
303306
304307.. index :: single: slicing
305308
306309Sequences also support slicing: ``a[i:j] `` selects all items with index *k * such
307310that *i * ``<= `` *k * ``< `` *j *. When used as an expression, a slice is a
308- sequence of the same type. This implies that the index set is renumbered so
309- that it starts at 0 .
311+ sequence of the same type. The comment above about negative indexes also applies
312+ to negative slice positions .
310313
311314Some sequences also support "extended slicing" with a third "step" parameter:
312315``a[i:j:k] `` selects all items of *a * with index *x * where ``x = i + n*k ``, *n *
You can’t perform that action at this time.
0 commit comments