title: Python - Finding and multiplying an integer after specific word
body: <p>I have a text file that has over 60,000 lines in it and I need to go through and find a specific word and then multiply the number after it. For example:</p>
  
  <pre><code>The cat jumped over the log
    tree 6
  the dog also jumped over the log
  tree 43
  </code></pre>
  
  <p>Would end up, if multiplying by 2, as:</p>
  
  <pre><code>The cat jumped over the log
    tree 12
  the dog also jumped over the log
  tree 86
  </code></pre>
  
  <p>I know this is fairly simple to do but I can't wrap my head around it. I need to step through the whole text file word by word looking for instances of "tree ", finding the integer after this, making the change, and then replacing the line. </p>
  
  <p>I also know that every occurrence of "tree " will always have an integer next to it. </p>
  
  <p>Thanks for your help.</p>
  
  <p>Edit:</p>
  
  <p>Current code I have as of now is:</p>
  
  <pre><code>file = open('export_desc.txt', 'r')
  
  a = "ext_mpl "
  for line in file:
      n = file.find(a+1)
      n = n*2
      file.write(line.replace(a+1, a+n))
  
  file.close()
  </code></pre>