Basta Fazoolin' Step 16 Help

Welcome to the Get Help category!

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!

I’m running into issues with Step 16 of Basta Fazoolin’. When I indent the return line on the available_menus function, it only returns the Brunch Menu, and when I unindent the return line to get it out of the for loop, it gives me the error:

Traceback (most recent call last):
File “script.py”, line 75, in
print(flagship_store.available_menus(1200))
File “script.py”, line 13, in available_menus
if time >= menu.start_time and time <= menu.end_time:
AttributeError: ‘dict’ object has no attribute ‘start_time’

I have the attribute ‘start_time’ defined in the class Menu, so I have no idea what the issue is. Can someone please help? Thank you!

class Franchise: def __init__(self, address, menus): self.address = address self.menus = menus def __repr__(self): return self.address def available_menus(self, time): self.time = 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 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) 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 #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 } brunch_menu = Menu('Brunch', brunch, 1100, 1600) #print(brunch_menu.calculate_bill(['pancakes', 'home fries', 'coffee'])) #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 } early_bird_menu = Menu('Early Bird', early_bird, 1500, 1800) #print(early_bird_menu.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)'])) #Dinner Menu #Early Bird Menu dinner = { 'crostini with eggplant caponata': 13.00, 'caesar 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, 1700, 2300) #Kids Menu kids = { 'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00 } kids_menu = Menu('Kids', kids, 1100, 2100) menus = [brunch_menu, early_bird, dinner_menu, kids_menu] flagship_store = Franchise('1232 West End Road', menus) new_installment = Franchise('12 East Mulberry Street', menus) #print(flagship_store) print(flagship_store.available_menus(1200))

What happens if you comment out or remove:
self.time = time

(in that function logic for available_menus )

Hi,
On line 68;
menus = […

One of these things is not like the others.

Hope that helps.

1 Like

1 Like