I think what you want is the following:
def search(query, ordering = 'normal', count = 10):
token_list = tokenisation(query)
matching_recipes = []
for recipe in recipes:
recipe_tokens = []
for key in recipe:
if type(recipe[key]) != list:
continue
if type(recipe[key]) == str:
recipe_tokens.append(recipe[key])
for sentence in recipe[key]:
# Make sure all the words from the recipes are in one big list
recipe_tokens.extend([t for t in sentence.split()])
if all([tl in recipe_tokens for tl in token_list]):
# check if all the tokens from token_list are in the tokens of the recipe
matching_recipes.append(recipe)
return matching_recipes
CLICK HERE to find out more related problems solutions.