title: Searching a 2-Dimensional Tuple/List in Python
body: <p>I want to search a <code>tuple of tuples</code> for a particular string and return the index of the parent tuple. I seem to run into variations of this kind of search frequently.</p>
  
  <p>What is the most pythonic way to do this?</p>
  
  <p>I.E:</p>
  
  <pre><code>derp = (('Cat','Pet'),('Dog','Pet'),('Spock','Vulcan'))
  i = None
  for index, item in enumerate(derp):
      if item[0] == 'Spock':
           i = index
           break
  &gt;&gt;&gt;print i
  2
  </code></pre>
  
  <p>I could generalize this into a small utility function that takes an iterable, an index (I've hard coded <code>0</code> in the example) and a search value. It does the trick but I've got this notion that there's probably a one-liner for it ;)</p>
  
  <p>I.E:</p>
  
  <pre><code>def pluck(iterable, key, value):
      for index, item in enumerate(iterable):
          if item[key] == value:
               return index
      return None
  </code></pre>