from math import ceil def chunk(arr, size): return list( map(lambda x: arr[x * size:x * size + size], list(range(0, ceil(len(arr) / size)))))