Skip to content

Keep the evens

Keep the evens

Filter a list: keep some items and leave the rest out.

Start with an empty list, loop over nums, and .append() each number that passes the test n % 2 == 0. Return the new list after the loop has finished.

Log in or create account

IGCSE, A-Level & AP