zip

Resources

  • Official documentation for the zip function.

zip

It is common to iterate over two iterators in parallel. We could try to implement it in the following way.

However, the zip functions allows us to accomplish this task in a less cumbersome way.

zip works by producing tuples with one item from each iterable at a time.

And then we use the standard tuple unpacking to access to the variables in the for loop.