Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 596e851

Browse files
committed
Completed Exercise 2.5: List of Dictionaries
1 parent 2dd9533 commit 596e851

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Work/report.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
def read_portfolio(portfolio_file):
55
"""
66
:param portfolio_file:
7-
:return: list of tuples for stock portfolio read from file given
7+
:return: list of dicts for stock portfolio read from file given
88
"""
99
portfolio_list = []
1010
with open(portfolio_file) as file:
1111
rows = csv.reader(file)
1212
headers = next(rows)
1313
for row in rows:
14-
portfolio_list.append((row[0], int(row[1]), float(row[2])))
14+
dict_holder = {"name": row[0], "shares": int(row[1]), "price": float(row[2])}
15+
portfolio_list.append(dict_holder)
1516
return portfolio_list

0 commit comments

Comments
 (0)