Sitemap
Apr 2, 2025

But it should be:

def get_even(numbers):
yield from (num for num in numbers if num % 2 == 0)

Get Tom Ritchford’s stories in your inbox

Join Medium for free to get updates from this writer.

The yield from keyword indicates that the function is a generator, and that’s better for type-checking and automatic tools.

--

--