#itertools

[ follow ]
#python
Python
fromMathspp
1 week ago

Who wants to be a millionaire: iterables edition

A Python quiz themed around iterables was presented at PyCon Lithuania 2026, featuring four questions and a performance.
fromMathspp
4 months ago

Generalising itertools.pairwise

itertools.pairwise is an iterable from the standard module itertools that lets you access overlapping pairs of consecutive elements of the input iterable. That's quite a mouthful, so let me translate: You give pairwise an iterable, like "ABCD", and pairwise gives you pairs back, like ("A", "B"), ("B", "C"), and ("C", "D"). In loops, it is common to unpack the pairs directly to perform some operation on both values.
Python
[ Load more ]