Purify - what's wrong?


#1


Hi all!

I got stucked in this exercise and I don't know why.
I executed that code, using my installed python interpreter and received correct results.
Here on codecademy the following error return:

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


def purify(lst):
    nwlst=[]
    for item in lst:
        if item % 2 == 0:
            nwlst.append(item)
    return nwlst


#2

...strange things going on here!
I tried again and now it works!
I didn't change anything, the code seems to work!


#3

That worked for me too :slight_smile:

def purify(list):
    results = []
    for item in list:
        if item % 2 == 0:
            results.append(item)
    return results

#4

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