title: In a list of strings, find a phrase within the string and append two integers (x..y) in string to a list . Python
body: <p>So i'm trying to write a script that reads a file and extracts 2 values once a certain word is found.  In this case, when the string 'exon' is encountered it will save the two integers that follow it.</p>
  
  <p>I started by creating empty strings:</p>
  
  <pre><code>exon_start = []
  exon_end = []
  </code></pre>
  
  <p>Here is an example of the simplified data I am using:</p>
  
  <pre><code>for line in data:
      print data
  
  &gt;&gt;&gt;
  
   exon            1..35
                   /gene="CDKN1A"
  
   CDS             73..567
                   /translation="MSEPAGDVRQNPCGSKACRRLFGPVDSEQLSRDCDALMAGCIQE
                   ARERWNFDFVTETPLEGDFAWERVRGLGLPKLYLPTGPRRGRDELGGGRRPGTSPALL
                   QGTAEEDHVDLSLSCTLVPRSGEQAEGSPGGPGDSQGRKRRQTSMTDFYHSKRRLIFS
                   KRKP"
  
   misc_feature    76..78
                   /gene="CDKN1A"
  
  
   exon            518..2106
                   /gene="CDKN1A"
  </code></pre>
  
  <p>I tried importing regular expression module for the re.findall() function:</p>
  
  <pre><code>indx_exon = range(0,len(data))
  
  # so this relates each line of the data to a specific number in the index
  </code></pre>
  
  <p>i'm having trouble recognizing the 'exon' phrase within each individual line
  first i just tried to identify which line of the text had the exon sequence to see if the re.findall() was working and I put:</p>
  
  <pre><code>for p,line in zip(indx_line,data):
  
      if re.findall(r'exon',line) is True:
          print p
  </code></pre>
  
  <p>and I got None</p>
  
  <p>when I put:</p>
  
  <pre><code>for p,line in zip(indx_line,data):
  
      exon_test = re.findall(r'exon',line)
      print exon_test
  </code></pre>
  
  <p>i got a bunch of [] for the lines that did not contain 'exon' 
  and for the lines the did contain 'exon' they gave me 'exon' .  so i know that i can use the re.findall() feature to find every occurence of 'exon' within each of the strings</p>
  
  <p><strong>i just need to find out exactly how i can say when it finds the 'exon' it needs to look in that line until it finds '..' and then append the integers flanking it to their corresponding lists</strong>; i.e.</p>
  
  <pre><code>exon_start = [1,518]
  exon_end = [35,2106]
  </code></pre>