Slicing

Applies to: python

Slicing extracts a subsequence with seq[start:stop:step] (stop is exclusive). It works on lists, strings, and numpy arrays, and negative indices count from the end.

a = [0,1,2,3,4]
a[1:4]   # [1,2,3]
a[::-1]  # [4,3,2,1,0]  (reversed)

See also: array, numpy-array