Python#s zip Function: Aggregating Elements from Iterables

  • Share this:

Code introduction


The zip function takes multiple iterable arguments and returns an iterator that aggregates elements from each of the iterables into tuples.


Technology Stack : Built-in function

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip(*iterables):
    "zip(*iterables) -> zip object"
    "Create an iterator that aggregates elements from each of the iterables."
    iterator = iter(iterables)
    return map(object.__iter__, iterator)