Deviopath › Python

Keep Only Even Numbers

Easy · Lists

A comprehension can filter too: [x for x in items if condition] keeps only the items where the condition is true.

Write a function evens(numbers) that returns a new list with only the even numbers, in their original order.

Next: Largest Item Without max()