This commit is contained in:
Mike Bloy 2023-10-27 16:53:01 -05:00
parent 24d06f2169
commit e0a8cea2c4

View File

@ -21,3 +21,12 @@ def read_portfolio(filename):
rows = csv.reader(f)
_ = next(rows)
return [Stock(row[0], row[1], row[2]) for row in rows]
def print_portfolio(portfolio):
headers = ("name", "shares", "price")
fmtstr = "{0: >10} {1: >10} {2: >10}"
print(fmtstr.format(*headers))
print("{0:->10} {1:->10} {2:->10}".format("", "", ""))
for stock in portfolio:
print(fmtstr.format(stock.name, stock.shares, stock.price))