def copyStruct(inputStruct, outputValues):
    return [(copyStruct(subList, outputValues) if isinstance(subList, list)
         else next(outputValues)) for subList in inputStruct]
copyStruct(inputList, iter(flattenedResults))
What is the best way to separate a single list into multiple lists based on a pattern in Python?