I have a list like this:
[[8, \"Plot\", \"Sunday\"], [1, \"unPlot\", \"Monday\"], [12, \"Plot\", \"Monday\"], [10, \"Plot\", \"Tuesday\"], [4, \"unPlot\", \"
I have a helper function for the general case of partitioning a list in two:
def partition(iterable, condition):
def partition_element(partitions, element):
(partitions[0] if condition(element) else partitions[1]).append(element)
return partitions
return reduce(partition_element, iterable, ([], []))
For example:
>>> partition([1, 2, 3, 4], lambda d: d % 2 == 0)
([2, 4], [1, 3])
Or in your case:
>>> partition(your_list, lambda i: i[1] == "Plot")