import more_itertools as mt #Create an array and use chunked() method iterable = range(11) n = 3 list(mt.chunked(iterable, n)) # [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]