Given a sequence of items and another sequence of chunk lengths, how can I split the sequence into chunks of the required lengths?
a = range(10)
l = [3, 5, 2]
split_lengths(a, l) == [[0, 1, 2], [3, 4, 5, 6, 7], [8, 9]]
Ideally a solution would work with both a and l as general iterables, not just on lists.
Use
itertools.isliceon an iterator of the list.or :