Purity(12)


#1



I'm having issues with this problem.

The error message is "'NoneType' object has no attribute 'append'"

I thought I defined all values before sending it, but it's saying that there is no object to append to. I'm unsure if my use of the loops if perfectly correct but i thought I had a decent understanding of them. Thanks for any help.


my code is

def purify(lst):
    new_lst = []
    for o in lst:
        if o%2 == 0:
            new_lst = new_lst.append(o)
    return new_lst


#2

The assigning isn't needed, just append the element, the way you did it is fine.


#3

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