I have two lists of the same length. The first list l1 contains data.
l1 = [2, 3, 5, 7, 8, 10, ... , 23]
The second list l2 contains a category in which data in l1 belongs to:
l2 = [1, 1, 2, 1, 3, 4, ... , 3]
How can I split the first list based on positions defined by numbers, such as 1, 2, 3, 4 in the second list, using list comprehension or lambda function. For example, 2, 3, 7 from the first list refers to the same section as the corresponding values ββin the second list.
The number of sections is known at the beginning.
source share