Skip to content

Commit 5d6bf62

Browse files
committed
Updated to Exercise 2.11: Adding some headers
1 parent d237b0b commit 5d6bf62

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Work/report.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# report.py
32
#
43
# Exercise 2.4
@@ -57,6 +56,9 @@ def make_report(portfolio, prices):
5756

5857
print(f'Gain: {total_value:0.2f}' if total_value > 0 else f'Loss: {-total_value:0.2f}')
5958

59+
headers = ('Name', 'Shares', 'Price', 'Change')
60+
print('%10s %10s %10s %10s' % headers)
61+
print(('-' * 10 + ' ') * 3 + '-' * 10)
6062
report = make_report(portfolio, prices)
6163
for name, shares, price, change in report:
62-
print(f'{name:>10s} {shares:>10d} {price:>10.2f} {change:>10.2f}')
64+
print(f'{name:>10s} {shares:>10d} {price:>10.2f} {change:>10.2f}')

0 commit comments

Comments
 (0)