Zip Function Implementation

  • Share this:

Code introduction


This function takes multiple iterable arguments and returns a list of tuples, with each tuple containing elements from each input iterable at the same index.


Technology Stack : zip

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip(*args):
    result = []
    for i in range(len(args[0])):
        result.append(tuple(arg[i] for arg in args))
    return result                
              
Tags: