Listing Your Problems 12. Purify question


#1



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


I have been stuck at this exercise for some time trying to figure out why I am continuing to get an error message. According to the instructions, it should be able to loop through a list of numbers and, if any are odd numbers, filter them out to preserve only a list of even numbers.

Instead, I am getting this error: "Oops, try again. Your code looks a bit off--it threw a "" error. Check the Hint if you need help!"

Any help is appreciated. I am new to this, so not quite sure how to interpret some of the more complicated explanations that I see when I have tried to search against this error...

My code is:


def purify(numbers):
    newnum = []
    while numbers > 0:
        for i in numbers:
            if i % 2 != 0:
                return False
            else:
                newnum.append(i)
    return newnum


#2

From what I can see.

  1. Match up the return statement with the appropriate loop
  2. Get rid of the the else / and return false statement. Not needed.
  3. Adjust your if statement so it checks for an even number(what you did in the is_even) section

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.