Untitled
unknown
plain_text
6 months ago
1.2 kB
2
Indexable
import json # Sample recipe database recipes = { "Pasta": ["pasta", "tomato sauce", "olive oil", "garlic"], "Omelette": ["eggs", "milk", "salt", "pepper", "cheese"], "Salad": ["lettuce", "tomato", "cucumber", "olive oil", "salt"], "Stir Fry": ["chicken", "broccoli", "soy sauce", "garlic", "ginger", "rice"], "Tacos": ["taco shells", "ground beef", "cheese", "lettuce", "tomato"], } def find_recipes(available_ingredients): available_set = set(available_ingredients.lower().split(", ")) matching_recipes = [] for recipe, ingredients in recipes.items(): if set(ingredients).issubset(available_set): matching_recipes.append(recipe) return matching_recipes def main(): print("Welcome to Dinner Chooser!") ingredients = input("Please enter the ingredients you have, separated by commas: ") # Find matching recipes matched_recipes = find_recipes(ingredients) if matched_recipes: print("\nYou can make: ") for recipe in matched_recipes: print(f"- {recipe}") else: print("Sorry, but you don't have enough ingredients for any of our recipes.") if __name__ == "__main__": main()
Editor is loading...
Leave a Comment