We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a8ec716 commit 9012611Copy full SHA for 9012611
1 file changed
Work/pcost.py
@@ -7,7 +7,12 @@ def portfolio_cost(filename):
7
with open(filename) as csvfile:
8
reader = csv.DictReader(csvfile)
9
for row in reader:
10
- total_cost += int(row['shares']) * float(row['price'])
+ try:
11
+ total_cost += int(row['shares']) * float(row['price'])
12
+ except ValueError as err:
13
+ print(f'Invalid line at name {row["name"]}'
14
+ f'\nThe line is not used in the computation of Total cost'
15
+ f'\nErrormessage: {err}')
16
return total_cost
17
18
if __name__ == '__main__':
0 commit comments