relic7
3/12/2020 - 3:47 AM

Split a List into Evenly Distributed Chunks

# Method to split up your lists into chunks
def chunks(list, chunkSize):
    """Yield successive chunkSize-sized chunks from list."""
    for i in range(0, len(list), chunkSize):
        yield list[i:i + chunkSize]

# Use your `chunks` function to print out chunks of the same size
import pprint
pprint.pprint(list(chunks(range(10, 75), 10)))