Skip to content · ⁨Saltar al contenido⁩

Keep the evens · ⁨Mantener los pares⁩

English

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.

Español

Mantener los pares

Filtrar una lista: mantener algunos elementos y descartar el resto.

Comience con una lista vacía, recorra nums y use .append() para cada número que pase la prueba n % 2 == 0. Devuelva la nueva lista después de que haya terminado el bucle.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP