Skip to content

Commit

Permalink
Update Grocery calculator.py
Browse files Browse the repository at this point in the history
Fixed inconsistent use of tabs and spaces in indentation
Updated print statements to match current syntax
  • Loading branch information
Piombacciaio authored Jul 30, 2023
1 parent f6bbb37 commit 5d90556
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Grocery calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@

#Object = GroceryList
#Methods = addToList, Total, Subtotal, returnList

class GroceryList(dict):

def __init__(self):
self = {}
def __init__(self):
self = {}

def addToList(self, item, price):
self.update({item:price})
def addToList(self, item, price):

self.update({item:price})

def Total(self):
def Total(self):
total = 0
for items in self:
total += (self[items])*.07 + (self[items])
return total

def Subtotal(self):
def Subtotal(self):
subtotal = 0
for items in self:
subtotal += self[items]
return subtotal

def returnList(self):
def returnList(self):
return self

'''Test list should return:
Expand All @@ -44,12 +44,12 @@ def returnList(self):
List1.addToList("kombucha", 3)


print List1.Total()
print List1.Subtotal()
print List1.returnList()
print(List1.Total())
print(List1.Subtotal())
print(List1.returnList())

#*****************************************************
print
print()
#*****************************************************


Expand All @@ -59,6 +59,6 @@ def returnList(self):
List2.addToList('wine', 25.36)
List2.addToList('steak', 17.64)

print List2.Total()
print List2.Subtotal()
print List2.returnList()
print(List2.Total())
print(List2.Subtotal())
print(List2.returnList())

0 comments on commit 5d90556

Please sign in to comment.