title: How to group list with index wise?
body: <p>I have a list of list where i need to group elements by using user input ( see <code>split</code> variable in code ) and create new list.
  I have tried but instead of grouping, elements are concatenated separately </p>
  
  <pre><code>split = 3 # user input 
  data = [[1,2], [3,4], [5,6], [7,8], [9,10], [11,12], [13,14], [15,16], [17,18]]
  z = [] ; y = []
  for i,d in enumerate(data):
      z.append(d)
      if (i+1)%split==0:
          y.append(z)
          z = []
  xx = (y+[z])
  print(xx)
  [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]], [[13, 14], [15, 16], [17, 18]], []]
  # ^____________________^    ^_______________________^  this needs to be merged
  </code></pre>
  
  <p>input :</p>
  
  <pre><code>data = [[1,2], [3,4], [5,6], [7,8], [9,10], [11,12], [13,14], [15,16], [17,18]]
  </code></pre>
  
  <p>expected output :</p>
  
  <pre><code>[[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]]
  </code></pre>