12.purify stucked here..!


#1



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


def purify(numbers):
    n=numbers
    for i in n:
        if i%2==0:
            print i
        else:
            break


#2

@dataace98389
The instructions
Define a function called purify that takes in a list of numbers,
removes all odd numbers in the list, and returns the result.

For example, purify([1,2,3]) should return [2].

Do not directly modify the list you are given as input;
instead, return a new list with only the even numbers.


#3

First of all,

n=numbers

doesn't create a copy of the list, numbers, called n. It just created another variable name (n) for the same list. So when you change n or numbers, it will affect the same list.Try creating a new empty list or use another method to copy the list.
Another thing is, if you put

else:
    break

in the loop, you are basically saying, if an item in the list is not even, exit the loop. So, if your list is this: [1,2,3], when the code runs on the first item, 1, it will exit the loop and produce the list [1,2,3] as you did nothing to it. You don't necessarily need this.

I believe you also forgot a return statement.