title: How to overcome TypeError: unhashable type: 'list'
body: <p>I'm trying to take a file that looks like this:</p>
  <pre class="lang-none prettyprint-override"><code>AAA x 111
  AAB x 111
  AAA x 112
  AAC x 123
  ...
  </code></pre>
  <p>And use a dictionary to so that the output looks like this</p>
  <pre><code>{AAA: ['111', '112'], AAB: ['111'], AAC: [123], ...}
  </code></pre>
  <p>This is what I've tried</p>
  <pre><code>file = open(&quot;filename.txt&quot;, &quot;r&quot;) 
  readline = file.readline().rstrip()
  while readline!= &quot;&quot;:
      list = []
      list = readline.split(&quot; &quot;)
      j = list.index(&quot;x&quot;)
      k = list[0:j]
      v = list[j + 1:]
      d = {}
      if k not in d == False:
          d[k] = []
      d[k].append(v)
      readline = file.readline().rstrip()
  </code></pre>
  <p>I keep getting a <code>TypeError: unhashable type: 'list'</code>. I know that keys in a dictionary can't be lists but I'm trying to make my value into a list not the key. I'm wondering if I made a mistake somewhere.</p>