Similar to Strings, we can also slice a List by providing a range of indices within [x:y]
. If we don't provide the x
index, all elements starting from 0
up to y
will be fetched. If we don't provide the y
index, all values starting from x until the end of the list will be fetched.
We could also use negative indices.