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!

Why doesn't work? I have no idea

def purify(numbers):
    new_numbers = []
    for i in numbers:
        if numbers[i] % 2 == 0:
    return new_numbers


When you use a for loop, you iterate through each item in the list. The variable that you used as i will be each item in the list, so if there is a number in the list that's higher than the length of the list, the way you wrote it, it will try to find a number at an index that's not there. Just check if i is even and not numbers[i].


Thanks so much. :slight_smile:


def purify(numlist):
purlist = []
for i in range(len(numlist)):
if int(numlist[i]) % 2 == 0 and int(numlist[i]) >= 2:
return purifylist


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