title: PYTHON dictionary and look up table
body: <p>This is my first post and am new to programming so please excuse my novice mistakes in asking a question:</p>
  
  <p>I have two files in the tabular format:</p>
  
  <p><code>IDs.txt</code> is just a list of IDs that looks like this:</p>
  
  <pre><code>1
  2
  3
  4
  7
  </code></pre>
  
  <p><code>dictionary_FE.txt</code> is a dictionary of sorts with 2 columns that are tab delimited and looks like this:</p>
  
  <pre><code>1    a
  2    b
  5    h
  7    g
  </code></pre>
  
  <p>where a key is associated with a value.  I would like to write a python code to get me a new file that takes the IDs in <code>IDs.txt</code> and looks them up in <code>dictionary_FE.txt</code>.  Not all the IDs in <code>IDs.txt</code> will be in <code>dictionary_FE.txt</code>.  I would like a file that looks like this:</p>
  
  <p><code>File3.txt</code> as output:</p>
  
  <pre><code>1    a    
  2    b
  3    'not found'    
  4    'not found'    
  7    g
  </code></pre>
  
  <p>The following is what I have written:</p>
  
  <pre><code>#!/usr/bin/env python
  
  infile1=open("dictionary_FE.txt", "r")
  infile2=open("IDs.txt", "r")
  
  F=infile1.readlines()
  
  for item in infile2.readlines():
      item=item.strip()                       
      for line in F:
          line=line.strip()
          line=line.split('\t')
          ide=line[1]
          if item == ide:
              print line[0]+"\t"+item
  </code></pre>
  
  <p>I get a blank output. </p>