We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6aebd14 commit c8e5a1aCopy full SHA for c8e5a1a
Work/portfolio.py
@@ -5,6 +5,15 @@ def __init__(self, holdings):
5
def __iter__(self):
6
return self._holdings.__iter__()
7
8
+ def __len__(self):
9
+ return len(self._holdings)
10
+
11
+ def __getitem__(self, index):
12
+ return self._holdings[index]
13
14
+ def __contains__(self, name):
15
+ return any([s.name == name for s in self._holdings])
16
17
@property
18
def total_cost(self):
19
return sum([s.cost for s in self._holdings])
0 commit comments