title: Find the last element in a row that matches a criterion
body: <p>In addition to this question "<a href="https://stackoverflow.com/questions/2361426/get-the-first-item-from-an-iterable-that-matches-a-condition">Get the first item from an iterable that matches a condition</a>" I need the element one before the first match. Or fully equivalent: the last element in a row that matches a criterion. For example, if I need the last prime before the first non-prime in this list <code>[2, 3, 4, 5, 6, 7, 8, 9]</code>, the answer is 3. In case there is no such element the result could be None, an exception or a default value.</p>
  
  <p>The straightforward solution is:</p>
  
  <pre><code>result = None
  for x in numbers:
      if is_prime(x):
          result = x
      else:
          break
  </code></pre>
  
  <p>Is there a simple one-liner that solves the task?</p>