Can someone tell me why this code doesn’t work?
It only removes the first instance of the unwanted number, rather than each one, meaning if the list contains multiple instances of a number, it doesn’t remove each one in the ‘for’ loop
[spoiler]def purify(even_it): even = even_it for number in even: if number % 2 == 1: even.remove(number) return even[/spoiler]
but the opposite method works perfectly
[spoiler]def purify(even_it): even =  for number in even_it: if number % 2 == 0: even.append(number) return even[/spoiler]