def idf(total_word_freq, total_doc):#word_freq is a dict, total_doc is total number of documents
idf = {}
for word in total_word_freq:
idf[word] = math.log(total_doc/total_word_freq[word]) + 1
return idf
total_word_freq = word_freq(doc)
idf = idf(total_word_freq, len(textname))
UnboundLocalError: local variable 'idf' referenced before assignment
Why I got this?