words = {}
for key in list(programs.keys()):
    for w in key.split():
        w = w.lower()
if w not in words:
    words[w] = set()
words[w].add(key)

def lookup(search_string, words, programs):
    result_keys = None
for w in search_string.split():
    w = w.lower()
if w not in words:
    return []
result_keys = words[w] if result_keys is None else result_keys.intersection(
    words[w])
return [programs[k] for k in result_keys]
Find dictionary items whose key matches a substring