The purify problem


Can someone please help me of what is wrong here please?

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

I have tried filling some numbers in the array number list in the call function brackets but it still doesn’t work

def purify(lst):
    new_list = []
    for i in range(1, len(lst)+1):
        if i % 2 == 0:
    return new_list

print purify([])


for i in range(1, len(lst)+1):

here what is i ?It loops from 1 to the length of the lst.
But it should be loop through the values of the lst.then you should check whether or not the number( i in for loop ) divided by two has a remainder of 0.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.