title: python itertools round robin explaintation
body: <p>I came across this code snippet for round robin in <a href="https://more-itertools.readthedocs.io/en/latest/api.html" rel="noreferrer">https://more-itertools.readthedocs.io/en/latest/api.html</a>, but I couldn't understand how the last line <code>nexts = cycle(islice(nexts, pending))</code> removes the exhausted generator from nexts iterator. To my understanding, this removes the last one from input but shouldn't we remove the first one, i.e. the current one that throws this exception?</p>
  
  <pre><code>def roundrobin(*iterables):
      """Yields an item from each iterable, alternating between them.
  
          &gt;&gt;&gt; list(roundrobin('ABC', 'D', 'EF'))
          ['A', 'D', 'E', 'B', 'F', 'C']
  
      This function produces the same output as :func:`interleave_longest`, but
      may perform better for some inputs (in particular when the number of
      iterables is small).
  
      """
      # Recipe credited to George Sakkis
      pending = len(iterables)
      if PY2:
          nexts = cycle(iter(it).next for it in iterables)
      else:
          nexts = cycle(iter(it).__next__ for it in iterables)
      while pending:
          try:
              for next in nexts:
                  yield next()
          except StopIteration:
              pending -= 1
              nexts = cycle(islice(nexts, pending))
  </code></pre>