Skip to content

Commit da2224b

Browse files
I created a Python program that generates recipes and visualizes reac… (#17)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c4e5c1f commit da2224b

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

src/recipes/banana_pudding.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# src/recipes/banana_pudding.py
2-
31
def recipe_for_banana_pudding():
42
"""
53
Recipe for Banana Pudding
@@ -35,3 +33,56 @@ def recipe_for_banana_pudding():
3533
- If you want to make even more banana pudding, consider adding more bananas and increasing the sugar amount.
3634
- You can also add other ingredients like nuts or chocolate chips for extra flavor.
3735
"""
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

Comments
 (0)