def process_food_journals(food_journals, diet): """ Arguments: food_journals (list[list[str]]): A list of food journals, where each food journal is a list and the elements of each journal are strings representing the food in the journal. diet (set[str]): The food requirements of a diet, represented by a set of strings. Each string represents a food that should be in each food journal. Returns: list[list[str]]: A list of all journals that contain at least all of the foods in diet. """ good_journals = [] for food_list in food_journals: if meets_diet(food_list, diet): good_journals.append(food_list) return good_journals def meets_diet(foods, diet): """ Arguments: foods (list[str]): A food journal, represented by a list of strings. Each string represents a food item. diet (set[str]): The food requirements of a diet, represented by a set of strings. Each string represents a food that should be in each food journal. Returns: bool: Should return True if all of the strings in diet are contained in foods, and False otherwise. """ for diet_item in diet: if diet_item not in foods: return False return True diet1 = set(["Banana", "Yogurt"]) journals1 = [\ ["Banana", "Mashed potatoes", "Carrots", "Yogurt"],\ ["Banana", "Yogurt"],\ ["Yogurt", "Yogurt", "Milk", "Ramen"],\ ["Banana", "Ramen", "Steak", "Cheese", "Banana"]] diet2 = set(["Pasta", "Apple juice", "Asparagus", "Cereal"]) journals2 = [\ ["Apple juice", "Asparagus", "Pasta", "Pasta", "Cereal"],\ ["Milk", "Cookies", "Juice"],\ ["Pecan pie", "Cereal", "Milk", "Asparagus", "Apple juice", \ "Milk", "Pasta", "Cheese"],\ ["Banana", "Asparagus", "Cereal", "Cereal"]] # These are the calls to the function print "The first diet requires:", diet1 print "The good food journals in journals1 for diet1 are:" print process_food_journals(journals1, diet1) print "\n--------------------------------------------------\n" print "The second diet requires:", diet2 print "The good food journals in journals2 for diet2 are:" print process_food_journals(journals2, diet2)