Say I have the following list:
l = [0,1,2,3,4]
If I choose some arbitrary index, for example, 3, and then do a subset:
l[3:]
The result is [3, 4]
However, if I choose a start index > len(l) (eg l[6:]
), I get the following result:
[]
Why do I get an empty list, rather than an exception? If I tried l[6]
, I would get:
IndexError: list index out of range
What is going on here? What is the reason for this behaviour?