title: python: loop through list of strings find index of specified element
body: <p>I'm sure this is simple and I'm looking right at it, but I cannot make it work. </p>
  
  <p>Goal: Use a loop to go through the list of strings and find the search term. 
  Return the element number of the first match. </p>
  
  <p>I've tried a few options, nothing seems to work, and I have yet to find a working description of how to do it in any texts. </p>
  
  <p>This is my best attempt so far: </p>
  
  <pre><code>def get_element_number(a_list, search_term):
      for i in range(len(a_list)):
        if search_term in a_list[i]:
          return a_list.index(i)
        elif not search_term in a_list:
          return 'no match'
  </code></pre>
  
  <p>Error message:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
  File "python", line 11, in &lt;module&gt;
  File "python", line 5, in get_element_number
  ValueError: 2 is not in list
  </code></pre>
  
  <p>Not looking for the complete answer, just any help in where I'm going wrong or if I'm missing something would be very helpful. </p>