title: slice (unsorted) array at value in python
body: <p>Given the array <code>a = [1,1,12,3,5,8,13,21]</code> I can slice off the first 3 elements like <code>a[:3]</code>  giving <code>[1,1,2]</code>. What I want is to slice off up to the element of vlaue <code>i</code> (e.g. if <code>i=8</code> I want <code>[1,1,12,3,5,8]</code> or <code>[1,1,12,3,5]</code> (I can work with either)). </p>
  
  <p>This works:</p>
  
  <pre><code>return a[:a.index(i)]
  </code></pre>
  
  <p>but only if I give it a value that's in the array.</p>
  
  <p><em>Is there a clean built in way to do this that does something sane on the missing value case?</em></p>