|
1 | | -# src/recipes/banana_pudding.py |
2 | | - |
3 | 1 | def recipe_for_banana_pudding(): |
4 | 2 | """ |
5 | 3 | Recipe for Banana Pudding |
@@ -35,3 +33,56 @@ def recipe_for_banana_pudding(): |
35 | 33 | - If you want to make even more banana pudding, consider adding more bananas and increasing the sugar amount. |
36 | 34 | - You can also add other ingredients like nuts or chocolate chips for extra flavor. |
37 | 35 | """ |
| 36 | + |
| 37 | +# Function to check if the recipe is valid |
| 38 | +def check_recipe(recipe): |
| 39 | + # Check basic ingredients are present in the recipe |
| 40 | + if "ripe bananas" not in recipe: |
| 41 | + return False, "Missing ripe bananas" |
| 42 | + if "vanilla extract" not in recipe: |
| 43 | + return False, "Missing vanilla extract" |
| 44 | + if "all-purpose flour" not in recipe: |
| 45 | + return False, "Missing all-purpose flour" |
| 46 | + if "granulated sugar" not in recipe: |
| 47 | + return False, "Missing granulated sugar" |
| 48 | + if "milk" not in recipe: |
| 49 | + return False, "Missing milk" |
| 50 | + if "salt" not in recipe: |
| 51 | + return False, "Missing salt" |
| 52 | + if "baking soda" not in recipe: |
| 53 | + return False, "Missing baking soda" |
| 54 | + if "butter, melted" not in recipe: |
| 55 | + return False, "Missing butter, melted" |
| 56 | + |
| 57 | + # Check directions are complete |
| 58 | + if len(recipe.split("\n")) < 8 or \ |
| 59 | + len(recipe.split("\n")[7]) == |
| 60 | + recipe = """ |
| 61 | + # Function to check if the recipe is valid |
| 62 | + def check_recipe(recipe): |
| 63 | + # Check basic ingredients are present in the recipe |
| 64 | + if "ripe bananas" not in recipe: |
| 65 | + return False, "Missing ripe bananas" |
| 66 | + if "vanilla extract" not in recipe: |
| 67 | + return False, "Missing vanilla extract" |
| 68 | + if "all-purpose flour" not in recipe: |
| 69 | + return False, "Missing all-purpose flour" |
| 70 | + if "granulated sugar" not in recipe: |
| 71 | + return False, "Missing granulated sugar" |
| 72 | + if "milk" not in recipe: |
| 73 | + return False, "Missing milk" |
| 74 | + if "salt" not in recipe: |
| 75 | + return False, "Missing salt" |
| 76 | + if "baking soda" not in recipe: |
| 77 | + return False, "Missing baking soda" |
| 78 | + if "butter, melted" not in recipe: |
| 79 | + return False, "Missing butter, melted" |
| 80 | + |
| 81 | + # Check directions are complete |
| 82 | + if len(recipe.split("\n")) < 8 or \ |
| 83 | + len(recipe.split("\n")[7]) == 0: |
| 84 | + return False, "Directions incomplete" |
| 85 | + |
| 86 | + # Additional checks can be added here if needed |
| 87 | + |
| 88 | + return True, "Recipe is valid" |
0 commit comments