Basta Fazoolin' - Stuck on Step 16

Got stuck on Step 16 in Bast Fazoolin’ exercise: https://www.codecademy.com/courses/learn-python-3/projects/basta-fazoolin

I’ve reviewed numerous posts from others with their code, and people’s responses, but in comparison, I cannot find what is different in mine compared to others’ who said their code was working. Please disregard my commented out lines of code, as I was trying to get fancy, then went back to the basics when I got stuck at Step 16. I should be seeing a list of available menus for the Franchise() name, time specified, but instead I either get “Brunch”, a blank list, or the repr statement from the Menus object/class itself. Soooo confused :stuck_out_tongue:

class Menu:
  start_convert = ""
  end_convert = ""
  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
#    if self.start_time > 12:
#      start_convert = str(self.start_time - 12) + "pm"
#    else: start_convert = str(self.start_time) + "am"
#    if self.end_time > 12:
#      start_convert = str(self.end_time - 12) + "pm"
#    else: start_convert = str(self.end_time) + "am"
    
  def __repr__(self):
    return self.name + " menu available from " + str(self.start_time) + "h to " + str(self.end_time) + "h."
    #return self.name #+ " is available from " + self.start_convert + " to " + self.end_convert + "."

  def calculate_bill(self, purchased_items):
    total = 0
    for item in purchased_items:
      total += self.items.get(item,0)
    return total


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},11,16)

early_bird = Menu("Early-Bird Dinners",{'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},15,18)

dinner = Menu("Dinner",{'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},17,23)

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

print(brunch)
print(brunch.calculate_bill(["pancakes", "home fries", "coffee"]))
print(early_bird.calculate_bill(["salumeria plate", "mushroom ravioli (vegan)"]))


class Franchise:
  def __init__(self, address, menus):
    self.address = address
    self.menus = menus
  def __repr__(self):
    return "We are located at " + self.address + "."
  def available_menus(self, time):
    self.time = time
    menu_list = []
    for menu in self.menus:
      if time >= menu.start_time and time <= menu.end_time:
        menu_list.append(menu)
      return menu_list

flagship_store = Franchise("1232 West End Road",[brunch, early_bird, dinner, kids])
print(flagship_store)
new_installment = Franchise("12 East Mulberry Street",[brunch, early_bird, dinner, kids])


print(flagship_store.available_menus(17))

In the Franchise class,
in the function available_menus,
change the indentation for return menu_list
to take it out of the for loop.

Right now, it returns menu_list after just checking the first menu,
You want it to check all the menus, add the appropriate menus to menu_list,
and then return menu_list when its done adding all the menus using the loop
(so the return must be outside the loop).

1 Like

Oh my gosh! Thank you!!! I’ve been pouring over this code for hours and missed that one extra indent! Thank you SO much for catching that for me!