Somehow my code isn’t running as I intented.
It is supposed to filter out the odd numbers.

def purify(numbers):
    for number in numbers:
      if number % 2 != 0:
    return numbers

print purify([3, 4, 7, 7, 7])

It should remove all odd numbers and print [4] but it prints [4, 7]


have you checked for existing topics, it took me less then 30 seconds to find this:

Practice Makes Perfect, anti_vowel, 8/15

although this is anti-vowel, you have the same removal problem.


Thx a lot, now I know it is bad idea to remove from list I am looping. Next time I will look into old topics. :+1:


This topic was automatically closed after 5 hours. New replies are no longer allowed.