code: def padded(iterable, fillvalue=None, n=None, next_multiple=False):
      
      it = iter(iterable)
      if n is None:
          yield from chain(it, repeat(fillvalue))
      elif n < 1:
          raise ValueError('n must be at least 1')
      else:
          item_count = 0
          for item in it:
              yield item
              item_count += 1
  
          remaining = (n - item_count) % n if next_multiple else n - item_count
          for _ in range(remaining):
              yield fillvalue
docs: Yield the elements from *iterable*, followed by *fillvalue*, such that
      at least *n* items are emitted.
  
          >>> list(padded([1, 2, 3], '?', 5))
          [1, 2, 3, '?', '?']
  
      If *next_multiple* is ``True``, *fillvalue* will be emitted until the
      number of items emitted is a multiple of *n*::
  
          >>> list(padded([1, 2, 3, 4], n=3, next_multiple=True))
          [1, 2, 3, 4, None, None]
  
      If *n* is ``None``, *fillvalue* will be emitted indefinitely.