code: def grouper(iterable, items, fillvalue=None):
      
      args = [iter(iterable)] * items
      return izip_longest(fillvalue=fillvalue, *args)
docs: Collect data into fixed-length chunks or blocks
  
      e.g:
  
          grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
  
      Got it from https://docs.python.org/2/library/itertools.html#recipes