12/15 purify error

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:
    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 [1] 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:
    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 :smile:

Why is this only return [4] when input is [4,5,5,4], instead of returning [4,4] ?

def purify(x):
        for y in x:
            if y%2==0:
            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. :smile:

That did the trick, appending it to the list instead of removing the odd numbers. Mucho gracias zeziba.

Not print
It should be return in a function

def purify(x):
lst =
if len(x) == 1:
for i in x:
if i % 2 == 0:
return lst

i have a same error TAT
my code is:
def purify(lists):

odd_numbers_list =
for number in lists:

if number % 2 != 0:


>return odd_numbers_list

print odd_numbers_list
i was told " Your function fails on purify([1]). It returns [1] 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