title: Type Error: unhashable type: list when using Python set of strings
body: <p>I know there's been several very similar answers here on SO on this exact question, but none of them really answer my question.</p>
  
  <p>I'm trying to remove a series of stop words and punctuation from a list of words to perform basic natural language processing.</p>
  
  <pre><code>from nltk.tokenize import word_tokenize, sent_tokenize
  from nltk.corpus import stopwords
  from string import punctuation
  
  
      text = "Hello there. I am currently typing Python. "
      custom_stopwords = set(stopwords.words('english')+list(punctuation))
  
      # tokenizes the text into a sentence
      sentences = sent_tokenize(text)
  
      # tokenizes each sentence into a list of words
      words = [word_tokenize(sentence) for sentence in sentences]
      filtered_words = [word for word in words if word not in custom_stopwords]
      print(filtered_words)
  </code></pre>
  
  <p>This throws a <code>TypeError: unhashable type: 'list'</code> error on the <code>filtered_words</code> line. Why is this error being thrown? I'm not providing a <code>list</code> collection at all- I'm providing a <code>set</code>?</p>
  
  <p>Note: I've read the post on <a href="https://stackoverflow.com/questions/13464152/typeerror-unhashable-type-list-when-using-built-in-set-function">SO on this exact error</a>, but still have the same question. The accepted answer provides this explanation:</p>
  
  <blockquote>
    <p><strong>Sets require their items to be hashable. Out of types predefined by
    Python only the immutable ones, such as strings, numbers, and tuples,
    are hashable.</strong> Mutable types, such as lists and dicts, are not hashable
    because a change of their contents would change the hash and break the
    lookup code.</p>
  </blockquote>
  
  <p>I'm providing a set of strings here, so why is Python still complaining?</p>
  
  <p>EDIT: after reading more into this <a href="https://stackoverflow.com/questions/26600462/unhashable-type-list-python">SO post</a>, which recommends using <code>tuples</code>, I edited my collection object:</p>
  
  <pre><code>custom_stopwords = tuple(stopwords.words('english'))
  </code></pre>
  
  <p>I also realized I have to flatten my list, since <code>word_tokenize(sentence)</code> will create a list of lists, and will not filter out punctuation correctly (since a list object will not be in <code>custom_stopwords</code>, which is a list of strings.</p>
  
  <p>However, this still begs the question- why are tuples considered hashable by Python but string sets not? And why does the <code>TypeError</code> say <code>list</code>?</p>