How can I fix my code so a search for football recipes returns a sorry no matches response
helpmicode

https://replit.com/@CFGRecipes/Recipes-Program-V1#main.py

import requests

app_id = '79f381d8'
app_key = '6d0c821df084f53a1ac53d1217343795'

def main():
global ingredient
ingredient = input('Find something to cook! \n \nTo get started, tell me which ingredient you\'d like in your recipe? \n')
results = recipe_search(ingredient)
results_by_ingredients = sort_by_ingredients(results, True)
#for i in results:
#if ingredient not in i['recipe']:
#print('Sorry, I did not catch that')
#else:
show_results(results_by_ingredients)
if len(results_by_ingredients) == 0:
print('Sorry, no results! Please start again and try a different ingredient.')

def recipe_search(ingredient):
url = 'https://api.edamam.com/api/recipes/v2/?type=public&q={}&app_id={}&app_key={}'.format(ingredient, app_id, app_key)

def sort_by_ingredients(r, reverse_order):
s = sorted(r, key=lambda i: len(i['recipe']), reverse = reverse_order)
return(s)

def show_results(search_results):
for i in search_results:
name = i['recipe']
source = i['recipe']
url = i['recipe']
number_ingredients = len(i['recipe'])
calories = i['recipe']
servings = i['recipe']
calories_per_serving = int(calories / servings)

main()

You are viewing a single comment. View All
helpmicode

@Coder100 thanks but please do not change code