I don't understand why my code isn't working

def purify(x):
    even_num = x
    for i in x:
        if i%i  != 1:
            even_num = even_num.remplace(i,"")
    return eve


i meant return even_num typo


The list type in Python does not have a replace() method. Creating a new list, appending the even values to it, and returning the new list would be a solution.


Thanks for your advice I got it by doing this
def purify(x):
even =[]
for i in x:
if i%2 == 0:
return even


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