Generator Error - not printing list returned in function from generator


Hi, i'm getting an error when I return the "new_lst" using this generator function.

Typically if I wrapped the function output in a 'print' or print( list( purify( [1,2,3] ) ) I get the resulting list to print out but it is not working this time. Any suggestions?

Error: generator object purify at 0x104a05990>

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



if you want to do this, use list comprehension, not a generator expression


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