title: python: creating a list inside a dictionary
body: <p>I just started using python and I'm trying to create a program that will read a file that looks like this:</p>
  
  <pre><code>AAA x 111
  AAB x 111
  AAA x 112
  AAC x 123
  ...
  </code></pre>
  
  <p>the file is 50 lines long and I'm trying to make the letters into keys in a dictionary and the numbers lists that correspond with the keys.</p>
  
  <p>I want the output to look 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("filename.txt", "r") 
  readline = file.readline().rstrip()
  while readline!= "":
      list = []
      list = readline.split(" ")
      j = list.index("x")
      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 syntax errors on my if statement and I can't figure out what I've done wrong.</p>