1+ import yaml
2+
13def recipe_for_banana_pudding ():
24 """
35 Recipe for Banana Pudding
@@ -33,8 +35,6 @@ def recipe_for_banana_pudding():
3335 - If you want to make even more banana pudding, consider adding more bananas and increasing the sugar amount.
3436 - You can also add other ingredients like nuts or chocolate chips for extra flavor.
3537 """
36-
37- # Function to check if the recipe is valid
3838def check_recipe (recipe ):
3939 # Check basic ingredients are present in the recipe
4040 if "ripe bananas" not in recipe :
@@ -54,35 +54,25 @@ def check_recipe(recipe):
5454 if "butter, melted" not in recipe :
5555 return False , "Missing butter, melted"
5656
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-
8157 # Check directions are complete
8258 if len (recipe .split ("\n " )) < 8 or \
8359 len (recipe .split ("\n " )[7 ]) == 0 :
84- return False, "Directions incomplete"
60+ return False , "
61+ # Check for special instructions
62+ if " This recipe uses ripe bananas " not in recipe :
63+ return False , "Missing special instructions: This recipe uses ripe bananas"
64+ if "The mixture can be adjusted to the desired consistency by adding more milk if needed." not in recipe :
65+ return False , "Missing special instructions: The mixture can be adjusted to the desired consistency by adding more milk if needed."
66+ if "You can also add other ingredients like nuts or chocolate chips for extra flavor." not in recipe :
67+ return False , "Missing special instructions: You can also add other ingredients like nuts or chocolate chips for extra flavor."
8568
86- # Additional checks can be added here if needed
69+ # Check for notes
70+ if "This is an excellent base recipe for making banana pudding." not in recipe :
71+ return False , "Missing notes: This is an excellent base recipe for making banana pudding."
72+ if "If you want to make even more banana pudding, consider adding more bananas and increasing the sugar amount." not in recipe :
73+ return False , "Missing notes: If you want to make even more banana pudding, consider adding more bananas and increasing the sugar amount."
74+ if "You can also add other ingredients like nuts or chocolate chips for extra flavor." not in recipe :
75+ return False , "Missing notes: You can also add other ingredients like nuts or chocolate chips for extra flavor."
8776
88- return True, "Recipe is valid"
77+ # If all checks pass, the recipe is valid
78+ return True , "Recipe for Banana Pudding is valid."
0 commit comments