Purify


#1

what is this error?

def purify(numbers):
    even=[]
    for i in numbers:
        if i%2==0:
            even.append[i]
    return even

Oops, try again. Does your purify function take exactly one argument (a list of numbers)? Your code threw a "'builtin_function_or_method' object has no attribute 'getitem'" error.


#2

.append() is a built in function to append items, but this requires parentheses, not square brackets.


#3

My code is almost exactly the same, and has appropriate parentheses, but it's still throwing an error code

def purify(unknown):
    final=[]
    for i in unknown:
        if i % 2 == 0:
            final =final.apprend(i)
    return final

(indentions are identical to the original post's)

Throwing error: "Your code looks a bit off--it threw a "'list' object has no attribute 'apprend'" error. Check the Hint if you need help!"


#4

append() will append to the list, no need to update the variable as well. append() is taken care of this for you


#5

But even when I take out the "final = " from in front of the append(), I get the same error. This is very frustrating.


#6

append shouldn't have the letter r in it (you have apprend)


#7

Durp. Thank you so much.


#8

A post was split to a new topic: Purify


#9

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