returning keys in a dictionary for every value in a list in python

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:
            if type(recipe[key]) == str:
            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

    return matching_recipes

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top