jrsmith3 / minimum_sugar

0 stars 1 forks source link

Write function to determine max value for particular restaurant menu item #13

Closed jrsmith3 closed 9 years ago

jrsmith3 commented 9 years ago

I've repeated code that looks like the following as of 3143fbf27d82a47403f891e938f48eda9f26bdbd

restaurant_name = "Taco Bell"

restaurant_menu_items = minimum_sugar.filter_menu_items(menu_data, "brand_name", restaurant_name)
restaurant_entree_items = minimum_sugar.filter_menu_items(restaurant_menu_items, "menu_category", "entree")
max_sugar = max(minimum_sugar.extract_variable(restaurant_entree_items, "nf_sugars"))

print "Max sugar:", max_sugar
menu_items = minimum_sugar.filter_menu_items(restaurant_entree_items, "nf_sugars", max_sugar)
for menu_item in menu_items:
    print "Item name:", menu_item["item_name"]

in order to determine the entree menu item(s) containing the most sugar for a particular restaurant. This code should be factored into its own function instead of copying and pasting it all over the place.