Creating an inverted index in Python
Suggestions


You check all words in all documents. Try iterate only over docs (without unnecessary checks)
instead of create empty inv_indx = {i:[] for i in corpus_dict} you can use defaultdict


Code

from collections import defaultdict

inv_indx = defaultdict(list)
for idx, text in enumerate(docs):
    for word in text:
        inv_indx[word].append(idx)