Combining Iterables into an Iterator

  • Share this:

Code introduction


This function takes multiple iterable objects and combines them into an iterator. It yields a tuple with elements from each iterable on each iteration.


Technology Stack : Iterator

Code Type : Iterator

Code Difficulty : Intermediate


                
                    
def zip(*args):
    iterator = iter(args)
    for i in iterator:
        for j in i:
            yield j                
              
Tags: