Serhiy Storchaka <storchaka at gmail.com> writes: > def chunks(seq, size): > return [seq[i: i + size] for i in range(0, len(seq), size)] That's just for lists. An itertools version would work with arbitrary iterables. I've also had to rewrite that function more times than seems proper.