grouper

sknano.core.itertools.grouper(iterable, n, fillvalue=None)[source] [edit on github][source]

Collect data into fixed-length chunks or blocks.

Examples

>>> from sknano.core import grouper
>>> list(grouper('ABCDEFG', 3, '?'))
[('A', 'B', 'C'), ('D', 'E', 'F'), ('G', '?', '?')]