Keep the evens · Manter os pares
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.
Manter os pares
Filtre uma lista: mantenha alguns itens e exclua os demais.
Comece com uma lista vazia, percorra nums, e .append() cada número que passar no teste n % 2 == 0. Retorne a nova lista após o loop terminar.
Write evens(nums) that returns a new list holding only the even numbers from nums, in the same order. · Escreva evens(nums) que retorne uma nova lista contendo apenas os números pares de nums, na mesma ordem.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.