i am trying to make an inversed document index, therefore i need to know from all unique words in a collection in which doc they occur and how often.
i have used this an
if (word == keyword and dictionary[keyword][filename] is not None):
that is not a correct usage i guess, instead try this:
if (word == keyword and filename in dictionary[keyword]):
Because, checking the value of a non-existing key raise KeyError. :so You must check if key exists in dictionary...