Combining Iterables into Tuples with zip Function

  • Share this:

Code introduction


The function is used to combine multiple iterable objects into an iterator of tuples. It can accept an arbitrary number of iterable objects as arguments.


Technology Stack : zip function

Code Type : Function

Code Difficulty :


                
                    
def zip(*args):
    """将多个可迭代对象组合成一个个元组的迭代器。"""
    iterator = iter(args)
    return zip(*args)                
              
Tags: