0

Why it hasnot add the even to the list and print true and false and in the last..[] !!!

https://code.sololearn.com/cwlO2FTww92N/?ref=app

23rd May 2018, 10:13 PM
Omar
Omar - avatar
4 Respostas
+ 1
Because you function needs to return true when x even and false when x odd Try def isEven(x): Print(x%2==0) return x%2 == 0
23rd May 2018, 10:56 PM
Max
Max - avatar
+ 1
Because the function filters the list checking if the condition is true to fix your problem you can forget the filter and just do lis = [...] def is_even(num): print(num % 2 == 0) for elem in lis: is_even(elem)
23rd May 2018, 11:01 PM
TurtleShell
TurtleShell - avatar
+ 1
Filter goes through the list and applies the function to the list and the expects the function to return a Boolean value to filter, if it sees a that the function returned true it appends the element of the list it is looking at to the list it will output after it is finished looking through the list you gave to it as input
23rd May 2018, 11:04 PM
Max
Max - avatar
0
but why it need to return ?
23rd May 2018, 10:58 PM
Omar
Omar - avatar