File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -299,14 +299,17 @@ Sequences
299
299
These represent finite ordered sets indexed by non-negative numbers. The
300
300
built-in function :func: `len ` returns the number of items of a sequence. When
301
301
the 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 ``.
303
306
304
307
.. index :: single: slicing
305
308
306
309
Sequences also support slicing: ``a[i:j] `` selects all items with index *k * such
307
310
that *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 .
310
313
311
314
Some sequences also support "extended slicing" with a third "step" parameter:
312
315
``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