Practise Makes Perfect: 12: purify
Your function fails on purify([4, 5, 5, 4]). It returns [4, 5, 4] when it should return [4, 4].
I feel like this is the classic "Your loop breaks as soon as it hits 'return' " problem? It looks from the error at least that it is removing one odd number, so it seems like the function works but isn't looping.
Only I don't know how to resolve this...I can't nest the return function any lower (or do i mean higher?) without it being outside of the function.
Thanks in advance for your help
def purify(list): for n in list: if n % 2 != 0: list.remove(n) return list