title: Python3: How to increment a string value within a "for" loop
body: <p>I have a tabular.text file (Named "xfile"). An example of its contents is attached below.</p>
  
  <pre><code>Scaffold2_1 WP_017805071.1  26.71   161 97                    
  Scaffold2_1 WP_006995572.1  26.36   129 83       
  Scaffold2_1 WP_005723576.1  26.92   130 81   
  Scaffold3_1 WP_009894856.1  25.77   245 43  
  Scaffold8_1 WP_017805071.1  38.31   248 145   
  Scaffold8_1 WP_006995572.1  38.55   249 140    
  Scaffold8_1 WP_005723576.1  34.88   258 139   
  Scaffold9_1 WP_005645255.1  42.54   446 144
  </code></pre>
  
  <p>Note how each line begins with <code>Scaffold(y)_1</code>, with y being a number. I have written the following code to print each line beginning with the following terms, <code>Scaffold2</code> and <code>Scaffold8</code>.</p>
  
  <pre><code> with open("xfile", 'r') as data:
  
   for line in data.readlines():
       if "Scaffold2" in line:
         a = line
         print(a)
  
       elif "Scaffold8" in line:
         b = line
         print(b)
  </code></pre>
  
  <p>I was wondering, is there a way you would recommend incrementing the (y) portion of Scaffold() in the if and elif statements?</p>
  
  <p>The idea would be to allow the script to search for each line containing "Scaffold(y)" and storing each line with a specific number (y) in its own variable to be then printed. This would obviously be much faster than entering in each number manually.</p>