title: Counting specific words using def function and defaultdict
body: <p>I'm having issues with my code below. I'm trying to create a function that will create a count of headlines with specified words (see below); but I keep getting an error &quot;unhashable type: 'list'&quot;.</p>
  <p>rlist is a LIST but how else should I use the defaultdict method? My *args is &quot;the&quot;, &quot;and&quot;, and &quot;cat&quot;.</p>
  <pre><code>''' 
    create a function that will 
    create a count of headlines with specified words 
    rlist: the list of headlines in the list of lists format
    args: words to search for
    return: a dictionary of each specified word and its count
  '''
  
  def wordcount(rlist, *args):
      word_count = defaultdict(int)
      for headline in rlist:
          word_count[headline] += 1
          
      return word_count(args)
  
  print(wordcount(y2006_headline_lists, &quot;the&quot;, &quot;and&quot;, &quot;cat&quot;))
  </code></pre>