Purify error



Oops, try again. Your function fails on purify([1]). It returns [1] when it should return [].

Why don't this code work?

def purify(listofnum):
    new = []
    for index, element in enumerate(listofnum):
        if element % 2 != 0:
    return new


the remainder of even numbers is zero, the remainder of odd numbers is one

Your if condition evalutes to true for odd numbers. You want a list with the even numbers


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