Basta Fazoolin' AttributeError

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

for this line, I would get an error as follow:

Traceback (most recent call last):
File “”, line 56, in
File “”, line 43, in available_menus
if time >= menu.start_time and time <= menu.end_time:
AttributeError: ‘str’ object has no attribute ‘start_time’

I don’t understand why…

Hello @system3101586331, and welcome to the Codecademy Forums!

So that we can provide helpful advice, it would be useful for you to post your code. If you do so, please format the code for proper display. See How to ask good questions (and get good answers) for information on how to do this.

Make sure that you have created dictionaries for the Menu objects, and then instantiated those Menu objects properly and passed them within a list to any Franchise objects that you instantiate. Following is an example:

dinner_dict = {
  '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_dict, 17, 23)

arepas_dict = {
  'arepa pabellon': 7.00, 'pernil arepa': 8.50, 'guayanes arepa': 8.00, 'jamon arepa': 7.50
arepas_menu = Menu("Take a' Arepa", arepas_dict, 10, 20)

arepas_place = Franchise("189 Fitzgerald Avenue", [dinner_menu, arepas_menu])
1 Like

Sorry as I am new to Codecademy.
I have the following codes. And I was unable to get pass with the error I showed earlier AttributeError: ‘str’ object has no attribute ‘start_time’
However, I have no idea how and it just ran through after I tried to run it a few more times. It’s weird cause I have not changed anything…

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 '{} menu is available from {} to {}.'.format(, self.start_time, self.end_time)
  def calculate_bill(self, purchased_items):
    total = 0
    for item in purchased_items:   
      price = self.items.get(item)
      total += price 
    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', {
  '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', {
  '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,
}, 17, 23)

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

class Franchise:
  def __init__(self,address,menus):
    self.address = address
    self.menus = menus
  def __repr__(self):
    return "Our store is located at {location}.".format(location = self.address)

  def available_menus(self,time):
    self.time = time
    menulist = []
    for menu in self.menus:
        if time >= menu.start_time and time <= menu.end_time:
          for keys in menu.items:
    print (menulist)

Hi @system3101586331,

Something must have been accidentally changed in the code, because it no longer raises errors.

You are missing some lines of code for instantiating Franchise instances and calling their available_menus methods. Following is an example of how to do this:

# Instantiate a Franchise
arepas_place = Franchise("189 Fitzgerald Avenue", [dinner, kids])
# Display available menus at 12 noon

With that added to the end of the code that you posted, the output would be:

['chicken nuggets', 'fusilli with wild mushrooms', 'apple juice']

The reason why None is displayed at the end of the output is that your available_menus method displays results directly instead of having a return statement. See instruction 16. A possible way to write the code for that method that includes a return statement would be:

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

Edited on October 17, 2020 to add the following:

Link to project instructions: Basta Fazoolin’


Thanks very much. :+1:

1 Like