Solutions will be available when this assignment is resolved, or after a few failing attempts.

Is even and contains red

Write a function is_even_and_contains_red that receives a list (containing colors) and returns True if the list contains the color "red" AND has an even number of elements. False, otherwise. Check the examples:

# 4 elements (even) with red:
is_even_and_contains_red(['red', 'blue', 'green', 'white'])  # True

# 3 elements (odd!) with red:
is_even_and_contains_red(['red', 'blue', 'green'])  # False

# 2 elements (even!) **WITHOUT** red:
is_even_and_contains_red(['white', 'blue', 'green', 'black'])  # False

# 3 elements (odd!) **WITHOUT** red:
is_even_and_contains_red(['white', 'blue', 'green'])  # False

Test Cases

test even with red - Run Test

def test_even_with_red():
    assert is_even_and_contains_red(['red', 'blue', 'green', 'white']) == True

test even without red - Run Test

def test_even_without_red():
    assert is_even_and_contains_red(['black', 'blue', 'green', 'white']) == False

test odd with red - Run Test

def test_odd_with_red():
    assert is_even_and_contains_red(['red', 'blue', 'green']) == False

test odd without red - Run Test

def test_odd_without_red():
    assert is_even_and_contains_red(['blue', 'green', 'white']) == False
def is_even_and_contains_red(a_list): pass