I am trying to delete floating point values in a list that are negative. The original list with all of the values looks like this:
[
0.030079979253112028
You are iterating over and mutating the list which means you end up removing the wrong elements, you can use reversed:
for num in reversed(lst):
if num < 0:
lst.remove(num)
Or make a copy:
for num in lst[:]:
if num < 0:
lst.remove(num)
You can also use a list comp to modify the original list:
lst[:] = [num for num in lst if num >= 0]