| 10 | # Object = GroceryList |
| 11 | # Methods = addToList, Total, Subtotal, returnList |
| 12 | class GroceryList(dict): |
| 13 | def __init__(self): |
| 14 | self = {} |
| 15 | |
| 16 | def addToList(self, item, price): |
| 17 | self.update({item: price}) |
| 18 | |
| 19 | def Total(self): |
| 20 | total = 0 |
| 21 | for items in self: |
| 22 | total += (self[items]) * 0.07 + (self[items]) |
| 23 | return total |
| 24 | |
| 25 | def Subtotal(self): |
| 26 | subtotal = 0 |
| 27 | for items in self: |
| 28 | subtotal += self[items] |
| 29 | return subtotal |
| 30 | |
| 31 | def returnList(self): |
| 32 | return self |
| 33 | |
| 34 | |
| 35 | """Test list should return: |