I've written a code for purify (removing odd numbers from a list), but I can't work out what's wrong with it at all. It seems to fail when the list contains repeated odd numbers.
For example the error message I'm getting is Oops, try again. Your function fails on purify([4, 5, 5, 4]). It returns [4, 5, 4] when it should return [4, 4].
Also when I try purify([1,1,1,1,1,1]) it returns [1,1,1]
What's going on here? How do I fix it?
def purify(numbers): for c in numbers: if c%2 != 0: numbers.remove(c) return numbers