Printing Basta Fazooin available_menus as lineitems

Basta Fazoolin: https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-classes/projects/basta-fazoolin

When I got to Step16, my vision of the solution was to produce something like this:

print(flagship_store.available_menus(1700))

Menu Early Bird available 1500 to 1800
Menu Dinner available 1700 to 2300
Menu Kids available 1100 to 2100

And, I almost did it with this:

def available_menus(self, time):
        for menu in self.menus:
            if menu.start_time <= time <= menu.end_time:
                print(menu)

unfortunately ‘None’ gets added on the end as well.

I figured I use another for loop to iterate over the available_menus, but that was a mess.

Any ideas on what to do to?

Hello! The reason None gets printed is that you aren’t actually returning anything from the availale_menus function. This happens because when you

you’re printing the return value of the function. Since there is no return value, None gets printed.

2 Likes

Right , I get that.

return available_menus outputs:

[Menu Early Bird available 1500 to 1800, Menu Dinner available 1700 to 2300, Menu Kids available 1100 to 2100]

I tried iterating over available_menus:

for i in range(len(available_menus):
    print(available_menus[i])

with (predictably) the same result.

How do I convert that to the desired format without None?

You could simply call the function:

flagship_store.available_menus(1700)

Instead of printing that.

Well, just smack me in the head.

Thank you.

1 Like