DEV Community

Ruma Sinha
Ruma Sinha

Posted on

1

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more