I don't mean reversing, but slicing the last few elements, but then if the length of the slice goes further than the length of the list, it carries on from the start.
For example:
a = [1, 2, 3, 4, 5, 6]
Then if the slice starts at index 4 and is 5 elements long, the output is:
[5, 6, 1, 2, 3]
Any help is appreciated :)
Well if you want you can use itertools.cycle
and itertools.islice
this way it will wrap around to the start if the slice goes past the end of the list.
from itertools import cycle, islice
a = [1, 2, 3, 4, 5, 6]
start, length = 4, 5
print(list(islice(cycle(a), start, start+length)))
Result:
[5, 6, 1, 2, 3]