12. Purify



I get the following error message:

Oops, try again. Your function crashed on [1] as input because your function throws a "'int' object is not iterable" error.

It gives me the correct answer but won't say complete

numbers = [1,2,3,4,5,6,7]
def purify(l):
    for i in range(len(l)):
        if i % 2 ==0:
    return len(a)
print purify([1,2,2,6,4,1,3])
print purify(numbers)


Since we are not mutating the list, only scanning it, we can use a look up instead of a range.

for item in list:

When using a range, the iterator variable is the index, not the item.

for i in range(len(list)):
    if list[i] ...  : 


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