Purify exercise, Stuck


#1

Hi, I am stuck on how to solve this condition if this value is passed

purify([1])

Your function crashed on [1] as input because your function throws a “‘NoneType’ object is not iterable” error.

def purify(num):
    result = []
    for i in num:
        if i%2 == 0:
            result.append(i)
    print(result)


#2

weird error, not one that make sense

any way, you don’t return the result, which seems to cause the problem.


#3

@stetim94 yeah your right, can you tell me how return is different from print, and when you would use print and return?


#4

print and return do different things, so when to use depends on what you want to do

Ugh… i feel like i answer this question every other week

return is literally that, it returns (hands something back):

def example():
   return True
# store returned result in x variable
x = example()
# print the returned result
print x