def purify(x):
    for i in x:
        if i%2==0:
            print ('these are the even numbers:')
            print count
        return count

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


everything you need to purify the list should be inside the function, because count=[] is not inside the function, count will accumulate when the function is called multipy times

also, a function ends the moment a return keyword is reached

so currently, your function ends in the first itertion/run of your loop


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