title: How to slice Python list by the occurrences of an item?
body: <p>If given the following list <code>lst</code>:</p>
  
  <pre><code>import random as rnd, operator as op, itertools as it
  from functools import partial
  
  lst = [x for x in it.islice(it.cycle(range(1,10)), 50)]
  idx = set(rnd.sample(range(len(lst)), 10))
  for i in idx:
      lst.insert(i, 0)
  </code></pre>
  
  <p>How can I slice it by the occurrences of 0?</p>
  
  <p>My current strategy is this:</p>
  
  <pre><code>new_lst = [list(g) for k,g in it.groupby(lst, partial(op.eq, 0))]
  new_lst
  [[1, 2, 3, 4],
   [0],
   [5, 6, 7, 8, 9],
   [0],
   [1, 2],
   [0],
   [3, 4],
   [0],
   [5],
   [0],
   [6, 7, 8],
   [0],
   [9, 1, 2, 3, 4, 5, 6, 7],
   [0],
   [8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],
   [0],
   [1, 2, 3, 4, 5, 6],
   [0],
   [7],
   [0],
   [8, 9, 1, 2, 3, 4, 5]]
  </code></pre>
  
  <p>Note in the resulting <code>new_lst</code> I still have the separators, hence to achieve the <em>desired result</em> I have to iterate over once again:</p>
  
  <pre><code>new_lst = [i for i in new_lst if 0 not in i]
  new_lst
  [[1, 2, 3, 4],
   [5, 6, 7, 8, 9],
   [1, 2],
   [3, 4],
   [5],
   [6, 7, 8],
   [9, 1, 2, 3, 4, 5, 6, 7],
   [8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],
   [1, 2, 3, 4, 5, 6],
   [7],
   [8, 9, 1, 2, 3, 4, 5]]
  </code></pre>
  
  <p>Is there a more efficient way to do this?</p>