12. Purify problems


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/2?curriculum_id=4f89dab3d788890003000096


No idea why I'm getting this error: "Did you create a function called purify? Your code threw a "global name 'purify' is not defined" error." Any hints?


def purify(numlist):
    evenlist = []
    for num in numlist:
        if num % 2 = 0:
            evenlist.append(num)
        else:
            evenlist = evenlist
    return evenlist


#2

no need of this..

else:
            evenlist = evenlist

problem1
mentioned by @stetim94


#3

here:

if num % 2 = 0:

a single equal sign means assign

so we need to assign zero to the remainder of num divided by 2?

@greentreemee, true, bit unnecessary but not disasterous


#4

Agreed!It won't have effect on output of the code :slight_smile:


#5

Thank you @stetim94! Can't believe I missed that.

And thanks @greentreemee, good point.


#6