I have a list like this : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
and I want to extract the previous 'n' elements from a particular index.
For eg: If I take index 7, I have the element 8 in it. And for n = 3
, I want to get the previous 3 elements starting backwards from index 7. The result would be [5, 6, 7]
.
I am not able to come up with a slicing formula to get this. Could someone please help me?