slice

A copy of a run of items from a string, list or tuple, written s[start:stop], which includes start and stops just before stop.

In more detail

Leave out start to begin at the beginning and stop to go to the end, so s[:] copies the whole thing. A third number is a step, as in s[::-1] to reverse. Slices are forgiving: bounds past the end are simply cut short instead of raising an error.

Example

"program"[3:7]   # "gram"

Related terms

Taught in

References

Certification courses