Basically, I have this random meal code that asks the user to input the number 1. Once the user inputs the number 1, I want the if function to work and output the function create_recipe to create a randomly generated cake recipe. However, when the user inputs the number 1, the code does not work. How can I fix this? Is it because of my indentation? Please can someone help me. All responses are much appreciated. Here is the link: https://repl.it/@HarryBradley/ResponsibleForsakenAbilities#main.py Here is the code:
num = input("Enter the number 1 ")
if num == 1:
main_ingredient = ['chocolate', 'banana', 'salted caramel', 'carrot', 'bran']
baking = ['cake', 'brownie', 'cupcake', 'muffin']
measure = ['tbsp', 'tsp', 'cup']
ingredient = [ 'flour', 'baking powder', 'butter', 'milk', 'eggs', 'vanilla', 'sugar']
def create_recipe(main_ingredient, baking, measure, ingredient):
m_ingredient = random.choice(main_ingredient)
baking_ = random.choice(baking)
ingredients = [random.choice(ingredient)]
print("***", m_ingredient.title(), baking_.title() , "Recipe ***")
print("Ingredients:")
print(random.randint(1,3), random.choice(measure), m_ingredient)
for i in ingredient:
print(random.randint(1,3), random.choice(measure), i)
create_recipe(main_ingredient, baking, measure, ingredient)