12/15 purify


I don't understand which part of my code is worng.
plz give me some advice.

def purify(number):
    list_number = list(number)
    for i in list_number:
        if i % 2 == 0:
    return list_number

[12/15 purify](http://discuss.codecademy.com/t/12-15-purify/20255):

Before we test this, what information can you add, such as error message(s), console messages, instructions that might be difficult to understand, etc.?


As convenient as .remove() presents, the idea of altering a structure that we have intiated iteration of is not recommended. Instead, and since we are returning an object, create the object and return it,

def purify(numbers):
    nums = []
    for n in numbers:
        if n % 2 == 0:
    return nums


I wrote a very similar code :smile:
except I like to always start my variables with a,b,c...


My solution isn't the most elegant, but it did work

def purify(num_list): 
    pure_list=[] #The pure list 
    odd_list=[] #The Rejects 
    #Loop through the list 
    for num_element in num_list: 
        if num_element % 2 == 0:
    return pure_list;


The way to remove duplicates from a list is to start fresh with an empty list. Begin appending items to the list based on whatever criteria you have (in this case the item is even). This is my flattest function so far. I'm happy I finally have something to contribute.

def purify(this):
purified = [x for x in this if x % 2 == 0]
return purified


Where does the output go?

def purify(lst):
    return [x for x in lst if x %2 == 0]



This may help me with Exercise 14!