Purify - function doesn't take only one argument - what's wrong?


#1

This is the error message I get:

"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.

when I use the following code:

new = []
def purify(lst):
for x in lst:
if x % 2 == 0:
new.append[x]
elif x == 0:
new.append[x]
return new
print new

purify()

===
any input would be much appreciated! :slightly_smiling:


#2

Hi Nikki,

I believe you are trying to pass list new[] as an argument to your function def purify(lst):
but when you call your function "purify()" right at the bottom you do not specify the "new" list there

i have created a seperate code hope this works

`new = [4,5,6]
def purify(lst):
for i in range(0,len(lst)):
if new[i]%2==0:
lst.append(new[i])
if new[i]==0:
lst.append(new[i])

return lst

print purify(new)`

hope this helps