I have a list, a = [1,2,3,4]
from which I want to remove certain elements, say [2,4]
. I also want to keep a copy of that list. So, the obvious way to do that is b = a
and a.remove(2)
and then a.remove(4)
. Turns out that the removed elements are also removed from b
!!!
Why???
The problem is more complicated that removing two known numbers - I find their indexes on the fly and then remove these, so I need the original data in order to know which index to check... Any help will be highly appreciated.