title: Replace values in Python dict
body: <p>I have 2 files, The <a href="https://drive.google.com/file/d/0Bzv1SNKM1p4uV1ZNOE9ZVTc2dkk/view?usp=sharing" rel="nofollow">first</a> only has 2 columns </p>
  
  <pre><code>A   2
  B   5
  C   6
  </code></pre>
  
  <p>And the <a href="https://drive.google.com/file/d/0Bzv1SNKM1p4uZXJ2djBhMTlNX2c/view?usp=sharing" rel="nofollow">second</a> has the letters as a first column. </p>
  
  <pre><code>A  cat
  B  dog
  C  house
  </code></pre>
  
  <p>I want to replace the letters in the second file with the numbers that correspond to them in the first file so I would get.</p>
  
  <pre><code>2  cat
  5  dog
  6  house
  </code></pre>
  
  <p>I created a dict from the first and read the second. I tried a few things but none worked. I can't seem to replace the values.</p>
  
  <pre><code>import csv
  with open('filea.txt','rU') as f:
      reader = csv.reader(f, delimiter="\t")
      for i in reader:
          print i[0]  #reads only first column
          a_data = (i[0])
  
  
  dictList = []
  with open('file2.txt', 'r') as d:
          for line in d:
              elements = line.rstrip().split("\t")[0:]
              dictList.append(dict(zip(elements[::1], elements[0::1])))
  
  for key, value in dictList.items():
              if value == "A":
                      dictList[key] = "cat"
  </code></pre>