Python's Infinite Count Generator - Deepstash

Bite‑sized knowledge

to upgrade

your career

Ideas from books, articles & podcasts.

published 2 ideas

Python's Infinite Count Generator

🐍 Exploring itertools docs

Returns an infinite iterator that produces evenly spaced values starting with number start.

It's often used in combination with map() to generate consecutive data points, and with zip() to add sequence numbers.

STASHED IN:

2

Add sequence numbers

Assume you have three lists and you want to turn them into a table-like structure, where each row has a numeric ID.

You can combine count() with zip() to add sequence numbers to the resulting tuples. See code in image.

1

STASHED IN:

2

0 Comments

Discover and save more ideas by creating a

FREE

Deepstash account.

Develop a

reading habit

, save

time

and create an amazing

knowledge library

.

GET THE APP: