Courses/Functional Python

λ Functional Python

itertools Essentials

count, cycle, chain, islice, groupby — composable iterator tools.

itertools ships powerful, memory-efficient building blocks for working with iterators.

from itertools import islice, count, chain

first5 = list(islice(count(10, 2), 5))  # [10, 12, 14, 16, 18]
joined = list(chain([1, 2], [3, 4]))    # [1, 2, 3, 4]

groupby clusters consecutive equal items; accumulate produces running totals; product yields cartesian combinations.

main.py
Output
Press Run to execute.
Expected output
[1, 3, 6, 10, 15]

Sign in to track your progress across lessons.