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


in reply to Rosetta code: Split an array into chunks

Another Python solution:
>>> def formatter(data, chunksize=3): return ''.join( (' ' if i % chunksize else '\n') + d for i, d in enumerate(data))[1:] >>> print formatter(("a", "bb", "c", "d", "e", "f", "g", "h"), 3) a bb c d e f g h