Hello, I'm kinda stuck on this task, and can't figure out what's wrong with my code.


I tried several approaches, most of the time I get this Message:

Oops, try again.
Your code looks a bit off--it threw a "list index out of range" error. Check the Hint if you need help!

Here is the latest version of my code:

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

def purify(numbers):
    pure = []
    for num in numbers:
        if num%2!=0:
            return False
print purify(numbers)

Thanks in advance!



things I tried so far:

  1. add a print or return command to my else statement
  2. tried to create a variable for every desired value and later join them to a list


So, I tried to simplify the for loop which I feel is what is messy.

    for num in numbers:
        if num%2 ==0: #this checks if even
            pure.append(num) #appends those num that pass the even test to pure(which is an empty array)
    return pure #returns the for loop which checks for even

So, I really didn't make use of an else condition.

I hope this helps. :wink:


Thanks a million!

It's so simple, it hurts I didn't manage to do it myself :smiley:


You're welcome. Glad I could help! :wink:


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