Basta Fazoozlin

Still doing the same project(https://www.codecademy.com/courses/learn-python-3/projects/basta-fazoolin) Except now I am stuck on step 18. It is asking to me print a callback for 5pm. Here is my code so far:

class Franchise:

  def __init__(self, address, menus):

    self.address = address

    self.menus = menus

  def __repr__(self):

    return self.name + ' menu available from ' + str(self.start_time) + ' - ' + str(self.end_time)

  def available_menus(self, time):

    available_menus =[]

    for menu in self.menus: 

      if time >= menu.start_time and time <= menu.end_time:

        available_menus.append(menu)

    return available_menus

  

  def calculate_bill(self, purchased_items):

    bill = 0

    for purchased_item in purchased_items:

      if purchased_item in self.items:

        bill += self.items[purchased_item]

    return bill

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

brunch_items = {

  '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_menu = Menu('Brunch', brunch_items, 1100, 1600)

early_bird_items = {

   '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_menu = Menu('Early_Bird', early_bird_items, 1500, 1800)

dinner_items = {

  '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,

}

dinner_menu = Menu('Dinner', dinner_items, 1700, 2300)

kids_items = {

  'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00

}

kids_menu = Menu('Kids', kids_items, 1100, 2100)

menus = [brunch_menu, early_bird_menu, dinner_menu, kids_menu]

flagship_store = Franchise('1232 West End Road', menus)

new_installment = Franchise('1232 East Mulberry Street', menus)

#flagship_store.available_menus(1200)

print(flagship_store.available_menus(1700))

here is what gives me when I print:

[<__main__.Menu object at 0x7f6171bbd0f0>, <__main__.Menu object at 0x7f6171bbd160>, <__main__.Menu object at 0x7f6171bbd198>]

It is not giving me a line number so it is not an error and so I don’t know where to begin looking. any advice is welcome. please and thank you.

still no good. even when replacing rpr to str

it works when I used your code but put that __repr__ in the Menu Class instead of the Franchise class:

demonstration:

class Franchise: def __init__(self, address, menus): self.address = address self.menus = menus def available_menus(self, time): available_menus =[] for menu in self.menus: if time >= menu.start_time and time <= menu.end_time: available_menus.append(menu) return available_menus def calculate_bill(self, purchased_items): bill = 0 for purchased_item in purchased_items: if purchased_item in self.items: bill += self.items[purchased_item] return bill def __repr__(self): return "Franchise at address: \n" + self.address \ + "\n with menus: " + ", ".join( menu.name for menu in self.menus ) 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 self.name + ' menu available from ' + str(self.start_time) + ' - ' + str(self.end_time) brunch_items = { '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_menu = Menu('Brunch', brunch_items, 1100, 1600) early_bird_items = { '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_menu = Menu('Early_Bird', early_bird_items, 1500, 1800) dinner_items = { '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, } dinner_menu = Menu('Dinner', dinner_items, 1700, 2300) kids_items = { 'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00 } kids_menu = Menu('Kids', kids_items, 1100, 2100) menus = [brunch_menu, early_bird_menu, dinner_menu, kids_menu] flagship_store = Franchise('1232 West End Road', menus) new_installment = Franchise('1232 East Mulberry Street', menus) #flagship_store.available_menus(1200) print(flagship_store.available_menus(1700)) #print(flagship_store)
1 Like

Thanks. is codebyte free for using python? I notice this is a codebyte snippet.

I will try it tomorrow. I am baked from work today

A codeByte is just something available in Codecademy’s Forums [here] to run short snippets of code in some limited ways for a few languages. ( yes, free)
It’s kind of clunky to use … I just use it for short demonstrations in these forums occasionally.

nice thanks for the info.