Purify: Why isn't it adding to the list?


For some reason, the code doesn't attach the even numbers onto the list.

Every time I run it I get:
Oops, try again. Your function fails on purify([4, 5, 5, 4]). It returns [] when it should return [4, 4].

What have I done wrong?

def purify(num):
    num = []
    even = []
    for i in num:
        if i % 2 == 0:
    return even

print purify([666, 5, 4, 2])


Remove this line it is not doing anything in your code,

And change this line,

Remove the num[ ] so it should just be,



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.