I'm trying to write a list to rows with a specific number of columns. For example, take the list:
data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
I would like to write this out with a format such that it looks like:
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0,
10.0,
I've tried the following code; however, can only get it to print the first line:
strformat = ['{'+str(i)+':>5.1f},' for i in range(0,3)]
strformat = ''.join(strformat).lstrip().rstrip() + '\n'
print strformat.format(*[x for x in data])
Thanks in advance!