Python's Infinite Count Generator - Deepstash

Explore the World's Best Ideas

Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.

itertools.count(start=0, step=1)

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.

4

50 reads

Add sequence numbers

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.

3

26 reads

CURATED BY

ocpodariu

Alt account of @ocp. I use it to stash ideas about software engineering

CURATOR'S NOTE

🐍 Exploring itertools docs

More like this

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Access to 200,000+ ideas

Access to the mobile app

Unlimited idea saving & library

Unlimited history

Unlimited listening to ideas

Downloading & offline access

Personalized recommendations

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates