I have written this code and it works perfectly fine in the Python IDLE but it's not working in the codecademy's editor. def purify(lst): for i in range(1,len(lst)+1): if i%2==0: new_list.append(i) return new_list
Did you call your function?
have a look at this line
where does the
new_list come from?
its an empty list which i forgot to mention and yeah i called that function but i didnt pass the codecademy test
for i in range(1,len(lst)+1):
here what is
i ? It’s looping from
1 to the length of the
but it should be loop through the values of the
lst.then you can check whether or not the number (
i in the loop) is divided by two has a remainder of
new_numbers =  # to add something to an empty list you shoud declare it first…
for i in numbers: # when u specify range you are checking numbers from 1 to a length of input list
if i % 2 == 0:
this is my example
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.