In python the most elegant way to do this would be to use a generator function that will keep slicing the list into another list of given size. For example:
def chunk_list(data, chunk_size):
for i in range(0, len(data), chunk_size):
yield data[i : i + n]
data = [x for x in range(1, 51)] # Data to chunk
for chunk in chunk_list(data, 5):
print(chunk)
The generator function allows the caller to pause it's execution and return some value, in our case we are returning a small chunk of a list using the yield keyword.