DEV Community

Ruma Sinha
Ruma Sinha

Posted on

Python zip() function

Python zip function takes in iterables as arguments and creates an iterator.
A simple working example.

list of columns

columns = ["id","name","age","city","country"]

list of values

values = [111,"Mary John",35,"New York","USA"]

create an iterator with the zip function that takes in columns, values as the input parameters

zipped = zip(columns, values)

type(zipped) returns the value as zip

display the values

list(zipped)

Image description

Empty zip declaration

zipped = zip()

Image description

Top comments (0)