Basta Fazoolin' #17 problem

from datetime import datetime, time

class Menu:
  def __init__(self, name, items, start_time, end_time): = name
    self.items = items
    self.start_time = start_time
    self.end_time = end_time
  def __repr__(self):
    return "{name} menu available from {start} to {end}.".format(name =, start = self.start_time, end = self.end_time)  

  def calculate_bill(self, purchased_items):
    self.purchased_items = purchased_items
    total_bill = 0
    for item in self.purchased_items:
      total_bill += self.items[item]
      print(item, self.items[item])
    print('Total order:', total_bill)

brunch =  Menu("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
}, time(11,0), time(16,0))

early_bird = Menu("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,
}, time(15,0), time(18,0))

dinner = Menu("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,
}, time(17,0), time(23,0))

kids = Menu("kids", {
  'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00
}, time(11,0), time(21,0))

class Franchise(Menu):
  def __init__(self, address, menus):
    self.address = address
    self.menus = menus
  def __repr__(self):
    return "The restaurant is located at {address}".format(address=self.adrress)

  def available_menus(self, time):
    #self.time = time
    available_menus = [ ]
    for menu in self.menus:
      #if self.time >= self.start_time and time <= self.end_time:
      if menu.start_time <= time <= menu.end_time:
    return available_menus

flagship_store = Franchise("1232 West End Road", [brunch, early_bird, dinner, kids])   

new_installment = Franchise("12 East Mulberry Street", [brunch, early_bird, dinner, kids])

# test code

brunch.calculate_bill(['pancakes', 'home fries', 'coffee'])

early_bird.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)'])


There may code above. I can’t test out our .available_menus() method.
I get the TypeError: available_menus() takes 2 positional arguments but 3 were given


Thanks for posting! Could you edit your post and re-paste it after hitting the </> format button? It’ll make it easier to troubleshoot.

Welcome to the forums :slight_smile:

I am so sorry, I will change it.

But, I can’t use he pensil sign, I doesn’t work on my computer.

No need to apologize!

You just need to press this button:
Screen Shot 2020-10-29 at 10.08.18 AM

And then paste your code in between the tick marks (the three slashes)
Screen Shot 2020-10-29 at 10.08.24 AM

I’ve edited the post for you. :slight_smile:


This TypeError: available_menus() takes 2 positional arguments but 3 were given doesn’t seem to fit with your code, as the only time I see you invoking available_menus you give 1 positional argument.

Moreover, when I run your code it gives TypeError: '<=' not supported between instances of 'datetime.time' and 'int' which is another issue altogether. How have you progressed since your last post?

1 Like

Thanks for the assist!

1 Like