title: Most Pythonic Way to Split an Array by Repeating Elements
body: <p>I have a list of items that I want to split based on a delimiter. I want all delimiters to be removed and the list to be split when a <strong>delimiter occurs twice</strong>.  For example, if the delimiter is <code>'X'</code>, then the following list:</p>
  
  <pre><code>['a', 'b', 'X', 'X', 'c', 'd', 'X', 'X', 'f', 'X', 'g']
  </code></pre>
  
  <p>Would turn into:</p>
  
  <pre><code>[['a', 'b'], ['c', 'd'], ['f', 'g']]
  </code></pre>
  
  <p>Notice that the last set is not split.</p>
  
  <p>I've written some ugly code that does this, but I'm sure there is something nicer. Extra points if you can set an arbitrary length delimiter (i.e. split the list after seeing N delimiters).</p>