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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs