http://www.perlmonks.org?node_id=862342


in reply to Rosetta code: Split an array into chunks

The simplest Python version is probably:
def chunk_array(n, vals): return "\n".join(" ".join(vals[i:i+n]) for i in range(0, len(vals), n))
Given that you have to return one big string anyway, it's not worthwhile doing anything more fancy with generators/iterators.