Split a List into Chunks

easy
Unit 5 · Lists & Context Managers0/3 to milestone

Implement chunks(items, size) returning a list of lists of at most size items each, in order. The last chunk may be shorter. Raise ValueError if size < 1.

Also implement chunk_evenly(items, n): split into exactly n chunks whose lengths differ by at most one, with longer chunks first (like np.array_split).

#lists#iteration2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Split a List into Chunks · TechGradify