Practice makes perfect - purify


So, this is my code:

def purify(lst):
    for i in lst:
        if i %2 == 0:
    return lst2

However, both shell and codeacademy exercise throw the error: global name ‘lst2’ is not defined.
I tried adding global lst2 right at the beginning of my function but it says more or less the same. What am I doing wrong?

Thank you :slight_smile:




you want to store the even numbers in an empty list, why isn’t this list named lst2?


Hi! It’s because I tried that as well and it still didn’t work! I deleted and rewrote it again and now it passed:) Thanks!