Hello, can someone help me find out how to stop making it print out the transaction function when there is not enough ingredient to make the order. (I just started Python last week so my code has a lot of bugs. I also attach the description file of the project. Thanks
MENU = {
“espresso”: {
“ingredients”: {
“water”: 50,
“coffee”: 18,
},
“cost”: 1.5,
},
“latte”: {
“ingredients”: {
“water”: 200,
“milk”: 150,
“coffee”: 24,
},
“cost”: 2.5,
},
“cappuccino”: {
“ingredients”: {
“water”: 250,
“milk”: 100,
“coffee”: 24,
},
“cost”: 3.0,
}
}
resources = {
“water”: 300,
“milk”: 200,
“coffee”: 100,
}
is_on= True
money = 0
#is_sufficient = True
is_successful = True
while is_on:
order =input(“What would you like?”)
is_sufficient = True
if order ==“report”:
print(resources)
print(f"Money: {money}“)
def is_sufficient(order):
for ingredient in resources:
if resources[ingredient] < MENU[order][“ingredients”][ingredient]:
print(f"There is not enough {ingredient} to make {order}”)
return False
else:
return True
is_sufficient(order)
if is_sufficient:
for ingredient in resources:
resources[ingredient] -=MENU[order][“ingredients”][ingredient]
print(resources[ingredient])
print(“Please insert coins”)
quarters = int(input("Quarters: "))
dimes = int(input("Dimes: "))
nickles = int(input("Nickles: "))
pennies = int(input("Pennies: “))
def transaction(order,quarters,dimes,nickles,pennies):
print(“Please insert coins”)
total =quarters0.25+dimes0.1+ nickles0.05 +pennies0.01
cost =MENU[order][“cost”]
if total >=cost:
change = total - cost
print(f"Here is your change ${change}”)
return money +cost
else:
print(“Sorry that’s not enough money. Money refunded”)
is_successful = False
return is_successful
if is_sufficient:
transaction(order,quarters,dimes,nickles,pennies)
if is_successful and is_sufficient:
print(“Here is your drink. Enjoy”)