317 B
317 B
Exercise 1.3 - Solution
# pcost.py
= 0.0
total_cost
with open('Data/portfolio.dat', 'r') as f:
for line in f:
= line.split()
fields = int(fields[1])
nshares = float(fields[2])
price = total_cost + nshares * price
total_cost
print(total_cost)