I have a list of unknown length which I want to get the 5th to last, 4th to last, and 3rd to last elements from:
So if my list is like. a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to get. b = [6, 7, 8]
I can get this with b = a[6:9]
But the issue is my list could contain any number of items, so it could be.
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
and in this case b
should be [9, 10, 11]
which b = a[6:9]
does not give.
How can I always get the 5th to last third last items in a list, my list will always be over 5 elements long.