How to remove both occurrences of 333
from the below list?
>>> a = [-1, 1, 66.25, 333, 333, 1234.5]
I typed the below script in the Python 2.7 command line
for num in a:
if num == 333:
a.remove(num)
But only the first occurrence of 333
is removed
>>> a
[-1, 1, 66.25, 333, 1234.5]
How to remove all the occurrences of the same element? I want to be able to specify the element of which I want all the occurrences be removed and get a new list by the same name or another