Basta fazoolin' available.menus loop

Dear all,

quick question regarding loops in OOP.

Why does my code below not print out “brunch” and beneath it “kids”?
I get the solution and why I have to fill an empty list with the menus, but still don’t get why my “false” code below only spits out “brunch”.


class Franchise():

def init(self, address, menus):

self.address = address

self.menus = menus

def repr(self):

return self.address  

def available_menu(self, time):

for menu in self.menus:

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


Since you haven’t posted your full code, I can’t say for sure, but I would guess it is because of the way your for loop is set up, or more so, were you return statement is.

You loop through the menus and return the first one that meets the time requirements. That means only one of the items in menus will be returned. If bunch is before kids, it will be returned and then the function is terminated.