Any solution without creating a new list?


def purify(list):
new_list = []
for i in list:
if i%2 == 0:
return new_list


Yea, you could use .remove, but if you have a duplicate value, it will only remove on instance.

To overcome this problem, you could use list comprehension (this is going well outside the exercise). Let's say i have a list:

list = [1,2,3,4,5,6,2,4,6]

i could do:

list = [x for x in list if x % 2 != 0]

is list comprehension already covered in this point of the course?


Till now I didn't see any thing related to list comprehensions .

I referred to my notes from my previous training for the topic.I am familiar with the topic now. Thank you