I'm having some trouble figuring out how to slice python lists, it is illustrated as follows:
>>> test = range(10)
>>> test
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> test[3:-1]
[3, 4, 5, 6, 7, 8]
>>> test[3:0]
[]
>>> test[3:1]
[]
>>> test
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
To my understanding, python slice means lst[start:end], and including start, excluding end. So how would i go about finding the "rest" of a list starting from an element n?
Thanks a lot for all your help!
You can leave one end of the slice open by not specifying the value.
test[3:] = [3, 4, 5, 6, 7, 8, 9]
test[:3] = [0, 1, 2]