title: Locating index of item via REGEX in Python
body: <p>I've hit a wall and need some help.</p>
  
  <p>Context: I have a list of lists of strings.</p>
  
  <pre><code> Matrix = [['444'],
            ['23%'],
            ['A']]
  </code></pre>
  
  <p>For the moment, we have a list of Counts at position 0, Percentage at 1 and Significance test at 2. </p>
  
  <p>The number of lists within the list changes from 3 to 2 to 1 from time to time. And the type of string within the list changes position. So I cannot assume that index 0 will always be Counts and percentage will be 1 etc.</p>
  
  <p>Hence I wanted to find a way of dynamically finding out where percentage, for example, is located in the Matrix, and if its even in there. </p>
  
  <p>Here is what I've written so far: </p>
  
  <pre><code>for i, row in enumerate(Matrix):
      for cell in row:
          if "%" in cell:
              percent = i
              print percent
  for i, row in enumerate(Matrix):
      for cell in row:            
          if re.search('[a-zA-Z]', cell):
              sigtest = i
              print sigtest
  for i, row in enumerate(Matrix):
      for cell in row:
          if re.search('[0-9]', cell):
              count = i
              print count
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>1
  2
  0
  1
  </code></pre>
  
  <p>Problem: As you can see, the problem is located with the last for loop which records the fact that index 0 and 1 contain numbers. </p>
  
  <p>Whats needed: A way for the last for loop to search for numbers and numbers only, a item contains numbers and a symbol, that index should not be included. </p>
  
  <p>Hope that makes sense!</p>
  
  <p>thanks</p>