Removing an item from the list while looping over it changes the index location of the remaining items.
You can loop over a copy of the list and remove items from the original list
You can loop over a copy of the list and remove items from the original list
values=[6.2,5.9,4.8,6.1,6.1,6.5,5.9,5.8,6.2] for value in values[:]: if value<=6.0: values.remove(value) print(values)
Output:[6.2, 6.1, 6.1, 6.5, 6.2]
Also note that you shouldn't use list as the variable name to contain your list as it overwrites the keyword list