Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 364 Bytes

soln3_2.md

File metadata and controls

18 lines (12 loc) · 364 Bytes

Exercise 3.2 - Solution

(c) Table Formatter

# tableformat.py

# Print a table
def print_table(records, fields):
    print(' '.join('%10s' % fieldname for fieldname in fields))
    print(('-'*10 + ' ')*len(fields))
    for record in records:
        print(' '.join('%10s' % getattr(record, fieldname) for fieldname in fields))

Back