12. purify


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/2?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Your function fails on purify([4, 5, 5, 4]). It returns [4, 5, 4] when it should return [4, 4]


def purify(lst_nums):
    result_lst = lst_nums
    for num in lst_nums:
        print num
        if num % 2 != 0:
            print 'odd'
            result_lst.remove(num)
        print result_lst
    return result_lst

print purify([4, 5, 5, 4])


#2

remove is a difficult approach to solve this problem, because you loop over the same list as you remove from, this will not remove consecutive odd numbers.

append even numbers to a new list, that is a lot easier


#3

감사합니다 :wink: 감사합니다 :wink: 감사합니다 :wink: 감사합니다 :wink: 감사합니다 :wink: 감사합니다 :wink:


#4