Help with Classes and the Basta Fazoolin' Project

So I’ve been working on classes, and am now doing the Basta Fazoolin’ project and doing decently well with it. I’ve been doing a step or two, then using the video to check my answers. I think most of my code has been good, but when I go to test something it throws me an AttributeError, and I’m not sure why.

So, my main issue seems to be Step 16 and testing with 17. I’ll enter my code here and the full error that it keeps giving me.

class Franchise:
  def __init__(self, address, menus):
    self.address = address
    self.menus = menus

  def __repr__(self):
    return self.address

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

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 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 + " is available from " + str(self.start_time) + " until " + str(self.end_time)

# Brunch Menu

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)

#print(brunch_menu.calculate_bill(['pancakes', 'home fries', 'coffee']))

# Early Bird Menu

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)

#print(early_bird_menu.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)']))

# Dinner Menu

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 Menu

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("12 East Mulberry Street", menus)


And it is throwing this error:

Traceback (most recent call last):
File “”, line 91, in
AttributeError: ‘Franchise’ object has no attribute ‘available_menu’

I don’t know what exactly is causing the problem, so any help is appreciated :smiley:

You’re missing the ‘s’ in your available_menus() function call.

(Note: you wrote available_menu(1200))

Oops, I had messed with the letters because of the video… thats fixed but it returns another error that confuses me:

Traceback (most recent call last):
  File "", line 90, in <module>
  File "", line 12, in available_menus
    if time >= self.start_time and time <= self.end_time:
AttributeError: 'Franchise' object has no attribute 'start_time'

Hi again,

The proof is in the pudding as they say… :slight_smile:

The error message: 'Franchise' object has no attribute 'start_time' lets you know that Franchise class doesn’t have that attribute… and it doesn’t (the Menu class does). You would have to refer to a Menu object to avoid the error.

That makes sense… I’m just not sure how to do this part if that’s the case since I need to call a Franchise object to get the time/menus.

Well you have a menus attribute in Franchise. Is that supposed to hold a list of Menu objects? That might help when referencing the start time! When you write self in the Franchise class it will only refer to itself. If you want to refer to the menu you have to refer to the specific menu object.


I do have menus defined as a list of Menu objects, but its much lower down, around line 60. I’m still a bit lost after messing with it because the attribute that self.menus holds is different from the menus list, right? I should probably rewatch the guide video again.

I GOT IT! I was referring to self when using self.start_time, and the Franchise class didn’t have that, but menus did. I was just using the wrong word. Thanks for the help!

1 Like

:slight_smile: ! great!