<__main__.Menu object at ....>


I have a Problem with the output of “flagship_store.available_menus(12)”. I always get
“Folgende menus stehen zur Verfügung: [<main.Menu object at 0x7fc6db5bbc50>, <main.Menu object at 0x7fc6db5bbd30>]” but I want a list of the menus available at 12 o´clock.

class Franchise:
  def __init__(self, address, menus):
    self.address = address
    self.menus = menus
  def __str__(self):
    return (self.address)
  def available_menus(self, time):
    self.time = time
    z = []
    for i in self.menus:
      if (self.time >= i.start_time and self.time <=i.end_time):
    print(("Folgende menus stehen zur Verfügung: {}").format(z))

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 __str__(self):
    return ("{} menu is available from {} to {}".format(self.name, self.start_time, self.end_time))

  def calculate_bill(self, purchased_items):
    x = 0.
    for i in purchased_items:
      x += self.items[i] 
    return x

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)

Test_1 = ["pancakes", "home fries", "coffee"]
Test_2 = ["salumeria plate", "mushroom ravioli (vegan)"]

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



Hello, @lukis193129557867, and welcome to the forums!

In your code above, consider what the value being appended to z is versus what you wanted to append. Did you mean to append the entire menu object, or just one of its properties?

1 Like

Thank you very much, now it outputs the correct solution!
For all those who wants to know it, I have to append to my list only the name of the object so its “z.append(i.name)”.