solutions

Divisible numbers comprehension

Write a function that receives a list of numbers and a term 'n' and returns only the elements that are divisible by that term 'n'. You must use List comprehensions to solve it.

divisible_numbers([9, 8, 7, 6, 5, 4, 3, 2, 1], 3)  == [9, 6, 3]

Test Cases

test many divisible number - Run Test

def test_many_divisible_number():
    assert divisible_numbers([9, 8, 7, 6, 5, 4, 3, 2, 1], 3) == [9, 6, 3]

test empty list - Run Test

def test_empty_list():
    assert divisible_numbers([], 2) == []

test no result - Run Test

def test_no_result():
    assert divisible_numbers([2, 4, 8], 5) == []