I have a list (actually a pandas.DataFrame, but let's make it simple), let's say:
a = list(range(10))
I have to iterate on it and extract at each loop all the element from the beginning up to a "moving end". I want the whole list at the first iteration, drop the last element at the second iteration, drop the two last elements at third...and so on.
It seemed easy to code:
for i in range(5) :
print(i,a[:-i])
In fact this code works fine from "1" and later. But for i=0 I get an empty list, while I would like to get the full list.
I understand than "-0" is equal to "0" and that's why I am having this behaviour...but is there anything I could do about that?
Thanks!