12/15 please help to check


def purify(numbers):
for num in numbers:
if num%2!=0:
return new_num



The way you are going about it is kinda wonky.

Let's start with the baisics.

What is the problem?

Problem: Remove all odd numbers!

Ok next how do we do that?

if number % 2 == 0:

Ok so we can find our even numbers good. Now we need to collect only the even numbers.

even_numbers = []
for number in numbers:
    if number % 2 == 0:

When you use the method remove it will remove the first entry that it finds not all of them.

So instead of removing entries lets just build a list of the items that meet our quilifications.

list_numbers = [1, 2, 3, 4, 5, 6]
def purify(number_list):
    return_list = []
    for number in number_list:
        if number % 2 == 0:
    return return_list

It is harder to remove something then it is to make a new list with what you want.

Good luck!


Thank you so much for help me out!


You can also do something like this:

def purify(l):
    for i in l[:]:    # l[:] will create a copy of list you are looping through
        if i % 2 != 0:
    return l