title: split list comprehension into nested lists based on a rule
body: <p>I have a simple list splitting question:</p>
  
  <p>given a nested list like this:</p>
  
  <pre><code>x = [[1,4,3],[2,3,5,1,3,52,3,5,2,1],[2]]
  </code></pre>
  
  <p>I want to further split any element(sub-list) longer than 3, and whose length is a multiple of 3 or 3n+1 into sub-lists of length 3, except for the last chunk, so the result I want is:</p>
  
  <pre><code>x2 = [[1,4,3], [2,3,5],[1,3,52],[3,5,2,1],[2]]
  </code></pre>
  
  <p>I think it can be done with itertools.groupby and/or yield functions... but couldn't put together the details >> a_function(x)... </p>
  
  <pre><code> splits = [ a_function(x) if len(x)&gt;3 and (len(x) % 3 == 0 or len(x) % 3 == 1) else x for x in x]
  </code></pre>
  
  <p>Could anyone kindly give me some pointers? Thanks so much.</p>