Purify>>HELP


#1

def purify([1,2,3]):
is_even = []
for i in purify:
odd = (purify += 2)
if i == odd:
odd.remove()
return odd

This is my code, obviously something is wrong because it's not working. First Error is def purify([1,2,3]): says the syntax is wrong. Thank you.


#2

A parameter is a variable, not a literal object.

    def purify(old_list):

Removing elements from a list that is being iterated can have negative consequences. This is the sort of thing to avoid. You have an empty working list, so use it to collect only even numbers.

        new_list = []
        for i in old_list:
            if i % 2 == 0:        # test for even parity
                new_list.append(i)
        return new_list

#3

Thank you. I'm about to break it down to my understanding. I appreciate it.


#4

Your kind help has allowed me to understand the code! Thank you very much!


#5

A post was split to a new topic: Somehow it doesn't really work for me


#6