The function print_even_values takes an integer list as input and outputs each even number in the list. Calling print_even_values([2, 8, 1, 9, 0, 19, 24]) would generate the following result in the shell window:
2 8 0 24
My approach is:
def print_even_numbers(n:list) -> list:
'''Return a list of even numbers given a list of integers'''
for x in list:
if x % 2 == 0:
return(x)
assert print_even_numbers([2, 4, 2, 4, 5, 6]) == [2, 4, 2, 4, 6]
assert print_even_numbers([4, 1, 3, 2, 5, 9]) == [4, 2]
, but there is an error. Also, how do I make my output similar to the question? (i.e.
[2, 4, 2, 4, 6]
vs.(separate line)
2
4
2
4
6
Read Also : Has Taylor written a song about Matty Healy?
Answered 6 months ago
Luna Ella
The function print_even_values takes an integer list as input and outputs each even number in the list. Calling print_even_values([2, 8, 1, 9, 0, 19, 24]) would generate the following result in the shell window:
2 8 0 24
My approach is:
Read Also : Has Taylor written a song about Matty Healy?