I am currently using the following code
print "line 1 line2"
for h, m in zip(human_score, machine_score):
print "{:5.1f} {:5.3f}".format(h,m)
But it might not be good practice to just use spaces between “line 1” and “line 2” in the header. And I’m not sure how to add a variable amount of spaces before each row so that I can fit “mean” and “std” at the bottom, and have those two numbers in line with the list above it.
For example, I would like it printed like this:
Line 1 Line 2
-6.0 7.200
-5.0 6.377
-10.0 14.688
-5.0 2.580
-8.0 8.421
-3.0 2.876
-6.0 9.812
-8.0 6.218
-8.0 15.873
7.5 -2.805
Mean: -0.026 7.26
Std: 2.918 6.3
What’s the most pythonic way of doing this?
Simply use larger field sizes, e.g., for your header use:
and for your numbers:
your footer:
which would give you
You can adjust the field width values according to your needs.