I have a list of indices to exclude:
idx = [1, 3, 6]
and I want to automatically get 4 intervals/slices based on these indices, thanks to this post Split a list into parts based on a set of indexes in Python:
slices = [list[:1], list[2:3], list[4:6], list[7:]]
What is a pythonic way to do that?
** EDIT I solved it using a list comprehension and zip function:
'[list[i + 1: j] for i, j in zip([-1, *idx], [*idx, None])]