Purify NameError:


#1

I'm not sure that this is even remotely close to the problem solution but I am having issues with defining my variables. This isn't the first instance where I'm having problems. Can someone illuminate this for me?

Here is the code:

def purify(numbers):
    pure_list=[]
    if i in numbers %2 == 0:
        pure_list.append(i)
    return pure_list


This returns a NameError: Name "i" is not defined.
I thought that this is an arbitrary variable meant to act as a placeholder. Why does it need to be defined?


#2

it seems you confuse for in and if


#3

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