h may be shorter. >>> list(batched('ABCDEFG', 3)) [['A', 'B', 'C'], ['D', 'E', 'F'], ['G']] This recipe is from the ``itertools`` docs. This library also provides :func:`chunked`, which has a different implementation. i