← All tips

Python: use `any()` / `all()` for predicates

pythonpatterns

Readable checks over iterables.

nums = [1, 2, 3]
print(any(n > 2 for n in nums))