Purify


#1


I get the right answer. But get an error message - and would like to know where Im going wrong.

"Does your purify function take exactly one argument (a list of numbers)? Your code threw a "purify() takes exactly 2 arguments (1 given)" error."


new_list = []
def purify(numbers, divisor):
    for a in numbers:
        if a % divisor == 0:
            new_list.append(a)
    return new_list

print purify([1,9,3,4,8,10], 2)


#2

your function should have one parameter:

def purify(numbers):

it says so in the instructions, the divisor is always two, so you should just use the number 2 inside your function

Also, put new_list in side the function, the checking script calls your function, not the whole code, putting the new_list outside might means there remains numbers from earlier function calls by the checking script


#4

thanks. obvious now i look back at + thanks for the explanation regarding putting list in function.