Introduction

Python has a lot of built-in tools that allow us to iterate and transform data. A great example is the itertools module, which offers several convenient iteration functions. Each of these iterator-building functions (they generate iterators) can be used on their own, or combined.

The module was inspired by functional languages such as APLHaskell and SPL and the elements within itertools form Python’s iterator algebra.

Iterable vs Iterator

The count() Function

The cycle() Function

The chain() Function

#python #python's itertools #count() #count(), cycle() and chain() #python's itertools – count(), cycle() and chain() #chain()

Python's itertools – count(), cycle() and chain()
1.40 GEEK