12. For loop not working as expected


#1



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

Oops, try again. Your function fails on purify([4, 5, 5, 4]). It returns [4, 5, 4] when it should return [4, 4].

I expected it to complete successfully, but it's not removing all of the odd numbers for a reason I don't understand.


def purify (numbers):
    for x in numbers:
        if x%2==1:
            numbers.remove(x)
    return numbers


#2

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

I don't understand why two same odd number can't be removed if they are next to each other


#3

Try creating a new empty list and appending your positive results to that.


#5