Say I have a list like a = ["dog", "cat", "house", "mouse", "goose"]
. If I want to start a for loop at a[3]
and end it at a[2]
, how can I do that? a[3:2]
of course returns an empty list, so I can't iterate on that. Is there a more pythonic way to do that than iterating overa[3:]+a[:3]
?
To be clear, what I want is to have a for loop that starts at a[n]
, then goes to a[n+1]
, a[n+2]
etc until the end of the list; then, when the last element of the list is reached, the loop continues from a[0]
and goes on until a[n-1]
(the same thing that I obtain with a[3:]+a[:3]
).