What works
from math import ceil def func(array, x): num = ceil(len(array) / x) return [array[x * i:(x * i + x)] for i in range(num)]