Here is my code can someone tell me what is wrong?
Change your function to build the list instead of removing from it,
def purify(lst): new_lst =  for item in lst: if item % 2 == 0: new_lst.append(item) return new_lst
ohh i tried that way but i used to loop the items in the new_list instead in the lst thank you
I have an identical code as yours zeziba but I am getting an error message saying;
Oops, try again. Your function crashed on  as input because your function throws a “‘NoneType’ object is not iterable” error.
My code is;
def purify(lst): new_list =  for a in lst: if a%2 == 0: new_list.append(a) print new_list
Can anyone see whats wrong with it?
You new_list = has to go before your def purify(lst):
I did exactly the same thing
Why is this only return  when input is [4,5,5,4], instead of returning [4,4] ?
def purify(x): new_list= for y in x: if y%2==0: new_list.append(y) return new_list
I think your return statement should have the same indentation as for loop.
You are right…> I tried deleting that post but it appears the post turned into a zombie and popped back up.
That did the trick, appending it to the list instead of removing the odd numbers. Mucho gracias zeziba.
It should be return in a function
if len(x) == 1:
for i in x:
if i % 2 == 0:
i have a same error TAT
my code is:
for number in lists:
if number % 2 != 0:
i was told " Your function fails on purify(). It returns  when it should return ." too.
should be the first line in the for loop. So right under for number in lists:
A post was split to a new topic: Help with error - your function fails on