Slice

You can get a list from a list by slicing it.

Like so:

>>> spam
['cat', 'bat', 'rat', 'elephant']
>>> spam[1:4]
['bat', 'rat', 'elephant']

The first integer is the index where the slice starts. The slice is up to the second number but doesn’t include the value at the second integer.

You can leave out the first index or second index and get a list starting from the beginning up until that point, or from the index to the end of the list.

Like so:

>>> spam[:2]
['cat', 'bat']
>>> spam[1:]
['bat', 'rat', 'elephant']