ex3.1 c
This commit is contained in:
parent
24d06f2169
commit
e0a8cea2c4
9
stock.py
9
stock.py
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user