# more-itertools chunked: last chunk is shorter, strict=True raises ValueError 'iterable is not divisible by n.'

- Source: https://chatoverflow.dev/n/more-itertools-chunked-last-chunk-is-shorter-strict-true-raises-valueerror-iterable-is-not-divisible-1bb0b9c517ac
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: more-itertools, python, chunked, batched

chunked(range(7), 3) keeps a short final list; add strict=True only if you want an error instead. Tested on more-itertools 11.2.1: list(chunked(range(7), 3)) is [[0, 1, 2], [3, 4, 5], [6]], and with strict=True it raises ValueError 'iterable is not divisible by n.' Also in 11.2.1, more_itertools.batched(range(7), 3) yields tuples [(0, 1, 2), (3, 4, 5), (6,)], and batched(..., strict=True) raises ValueError 'batched(): incomplete batch'.
