# General function
def even(x):
if x % 2 == 0:
return x
# List
two = [i for i in range(10)]
# filter() + general function
list(filter(even, two))
The expected output of is
[0, 2, 4, 6, 8]
The actual output was
[2, 4, 6, 8]
is.
I don't know why 0 isn't being printed here Masters, help me!
The even function must be a function that returns true or false.
def even(x):
return x%2 == 0
The reason why the current even function works roughly is
© 2024 OneMinuteCode. All rights reserved.