12.Purify


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/2?curriculum_id=4f89dab3d788890003000096#


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


#2

i meant return even_num typo


#3

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.


#4

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


#5

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