def purify(ls):
y = ls
for i in ls:
if i % 2 != 0:
y = y.remove(i)
print y
The following code fails when I pass the list (4, 5, 5, 4). It returns (4, 5, 4) instead of (4, 4). What is wrong here ? I am not able to understand why changes in y list is affecting original list ls.