I am trying to remove all elements in an array that equal a target, a fairly simple procedure. For some reason though, it only removes the first element of the target in the array and I am not sure why. This is my code (python)
arr = [1,2,2,3,4,5,5]
for num in arr:
if num == 2:
arr.remove(num)
print(arr)
and it prints the array as [1,2,3,4,5,5]. If any of you know what went wrong that would be great. Thanks