2 ms·
I think the code is pretty ok, except for the stupid name, docstring and that it is a method and not a free function. def chunks(seq, n): "groups t
by bjourne 13y ago
I think the code is pretty ok, except for the stupid name, docstring and that it is a method and not a free function.
def chunks(seq, n):
"groups the elements of the seq into a list of n-sized chunks."
return zip(*[iter(seq)]*n)
- inglesp 13y agoThe original docstring is a complete red herring... yours is much better, but I'd go one further and include an example.