I want to remove all occurrences of a given element from a list but the problem is the way I'm doing I'm removing only half of it.
lsChars = ['x', 'y', 'a', 'a', 'a', 'a', 'b', 'c']
for c in lsChars:
if c == "a":
lsChars.remove(c)
print(lsChars)
The output is: ['x', 'y', 'a', 'a', 'b', 'c']
But should be: ['x', 'y', 'b', 'c']
How can I fix that?