The built-in slice function creates a slice object tha can be used anywhere a slice is allowed. There are three arguments to to fill in, start, end, and step. The object returns the values at the indices specified in the arguments. If you only provide one argument, by default, slice will interpret it as the end.

items = [0, 1, 2, 3, 4, 5, 6]
section = slice(2, 4, 1)
initial = slice(4)
items[section]
## [2, 3]
items[initial]
## [0, 1, 2, 3]

More on slices can be found here.