Calculate the frequency of words in python
Question: I have to calculate the frequency of each word which is there in text file if
it matches with the word which is there in an array but i am getting this
error **TypeError: unhashable type: 'list'**

    
    
    import string
    from collections import Counter
    from array import *
    cnt=Counter()
    word =[ ]
    word_count = [ ]
    new_array =['CC','CD','DT','EX','FW','IN','JJ','JJR','JJS','LS','MD','NN','NNS','NNP','NNPS','PDT',
                           'POS','PRP','PRP','RB','RBR','RBS','RP','SYM','TO','UH','VB','VBD','VBZ','WDT','WP','WP','WRB']
    file = open('output.txt', 'rU')
    for line in file:
          new_line = line.replace("_"," ")
          words = new_line.split()
          word.append(words)
    
    [(w, word.count(w)) for w in set(word) if w in new_array]
    


Answer: When you do `word.append(words)`, you are appending a list to a list, there by
making a list of lists. As a list is not hashable, a list of lists cannot be
converted into a set and you were getting that error.

I think you were intending to do `word += words` instead.

