12. purify



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'
        print result_lst
    return result_lst

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


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


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