Files
practical-python/Solutions/1_27/pcost.py
2020-05-27 17:03:35 -05:00

14 lines
287 B
Python

# pcost.py
total_cost = 0.0
with open('../../Work/Data/portfolio.csv', 'rt') as f:
headers = next(f)
for line in f:
row = line.split(',')
nshares = int(row[1])
price = float(row[2])
total_cost += nshares * price
print('Total cost', total_cost)