Basta Fazoolin's

Hey guys i don’t know what’s wrong with my code it keep printing the same value of summ
like the summ value is always 13.5

class Menu:
def init(self,name,items,start_time,end_time):
self.name =name
self.items =items
self.start_time =start_time
self.end_time = end_time

def repr(self):
return "{} {} available from {} to {} ".format(self.name,self.items,self.start_time,self.end_time)

def calculate_bill(self,purchase_items):
summ=0
for i in purchase_items:
if i in self.items:
summ += self.items[i]
return summ

brunch= {‘pancakes’: 7.50, ‘waffles’: 9.00, ‘burger’: 11.00, ‘home fries’: 4.50, ‘coffee’: 1.50, ‘espresso’:3.00, ‘tea’: 1.00, ‘mimosa’: 10.50, ‘orange juice’: 3.50}

brunch_bill=Menu(“brunch”,brunch,1100,1600)
print(brunch_bill.calculate_bill([‘pancakes’, ‘home fries’, ‘coffee’]))

dinner = {‘crostini with eggplant caponata’: 13.00,‘ceaser salad’: 16.00, ‘pizza with quattro formaggi’: 11.00, ‘duck ragu’: 19.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 2.00, ‘espresso’: 3.00}

early_bird ={‘salumeria plate’: 8.00, ‘salad and breadsticks (serves 2, no refills)’: 14.00, ‘pizza with quattro formaggi’: 9.00, ‘duck ragu’: 17.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 1.50, ‘espresso’: 3.00}

early_bird_bill=Menu(“early_bird”,early_bird,1100,1600)
print(early_bird_bill.calculate_bill([‘salumeria_plate’,‘mushroom ravioli (vegan)’]))

kids={‘chicken nuggets’: 6.50, ‘fusilli with wild mushrooms’: 12.00, ‘apple juice’: 3.00}

Hi,
In your second print statement, mushroom ravioli (vegan) is 13.50. For some_reason it’s not finding the price for the other_item. Cast your eyes back over it and you may find the issue.

Hope_that_helps

2 Likes