solutions

Even numbers using list comprehensions

Write a function that receives a list of numbers and returns only the even elements. You must use List comprehensions to solve it.

even_numbers([5, 4, 3, 2, 1]) == [4, 2]

Test Cases

test empty list even numbers - Run Test

def test_empty_list_even_numbers():
    assert even_numbers([]) == []

test no even numbers - Run Test

def test_no_even_numbers():
    assert even_numbers([5, 3, 7, 9, 1]) == []

test multiple even numbers - Run Test

def test_multiple_even_numbers():
    assert even_numbers([5, 4, 3, 2, 1]) == [4, 2]

test one even numbers - Run Test

def test_one_even_numbers():
    assert even_numbers([5, 4, 3, 7, 9, 1]) == [4]