Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Programming: Hi, need help with formatting the output. My output is : Ver

ID: 3671706 • Letter: P

Question

Python Programming: Hi, need help with formatting the output. My output is :

Vertices: (1.4, 2.3) , (3.2, 4.1) , (5.0, 6.9)
Perimeter is 11.72
Scalene triangle
Shortest side is 2.55
Area is 0.9
Obtuse

But, I need it to get it formatted in 2 columns and 3 rows like this:

Vertices: (1.4, 2.3), (3.2, 4.1), (5.0, 6.9)                    Shortest side is 2.55

Perimeter is 11.72                                                  Area is 0.90

Scalene                                                                 Obtuse

How do I format my output?

Explanation / Answer

l = ['Vertices: (1.4, 2.3), (3.2, 4.1)', '(5.0, 6.9)', 'Perimeter is 11.72', 'Scalene', 'Shortest side is 2.55', 'Area is 0.90', 'Obtuse'] if len(l) % 2 != 0: # dividing into 2 columns l.append(" ") split = len(l)/2 l1 = l[0:split] l2 = l[split:] for key, value in zip(l1,l2): print '%-20s %s' % (key, value) #python