File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#Object = GroceryList
10
10
#Methods = addToList, Total, Subtotal, returnList
11
-
12
11
class GroceryList (dict ):
13
12
14
- def __init__ (self ):
15
- self = {}
13
+ def __init__ (self ):
14
+ self = {}
16
15
17
- def addToList (self , item , price ):
18
- self .update ({item :price })
16
+ def addToList (self , item , price ):
17
+
18
+ self .update ({item :price })
19
19
20
- def Total (self ):
20
+ def Total (self ):
21
21
total = 0
22
22
for items in self :
23
23
total += (self [items ])* .07 + (self [items ])
24
24
return total
25
25
26
- def Subtotal (self ):
26
+ def Subtotal (self ):
27
27
subtotal = 0
28
28
for items in self :
29
29
subtotal += self [items ]
30
30
return subtotal
31
31
32
- def returnList (self ):
32
+ def returnList (self ):
33
33
return self
34
34
35
35
'''Test list should return:
@@ -44,12 +44,12 @@ def returnList(self):
44
44
List1 .addToList ("kombucha" , 3 )
45
45
46
46
47
- print List1 .Total ()
48
- print List1 .Subtotal ()
49
- print List1 .returnList ()
47
+ print ( List1 .Total () )
48
+ print ( List1 .Subtotal () )
49
+ print ( List1 .returnList () )
50
50
51
51
#*****************************************************
52
- print
52
+ print ()
53
53
#*****************************************************
54
54
55
55
@@ -59,6 +59,6 @@ def returnList(self):
59
59
List2 .addToList ('wine' , 25.36 )
60
60
List2 .addToList ('steak' , 17.64 )
61
61
62
- print List2 .Total ()
63
- print List2 .Subtotal ()
64
- print List2 .returnList ()
62
+ print ( List2 .Total () )
63
+ print ( List2 .Subtotal () )
64
+ print ( List2 .returnList () )
You can’t perform that action at this time.
0 commit comments