I have a list of objects and I want to get a list of a list of objects separated using objects from another list, for example:
l = ['x',1,2,3,'a',5,6,1,7]
and another list of objects
s = ['a', 1, 4]
And I want to get the result like this:
[ ['x'], [1, 2, 3], ['a', 5, 6], [1, 7] ]
Is there a good / pythonic way to do this?
EDIT:
I want the head of each listed list to be an s element, and all these lists keep the elements of the original list in the same order.
source share