Well, generally speaking, you should not remove items from the list that you iterate, because this will probably make you skip some items in the list.
Now about some other answer that is said here, yes, they work, but, strictly speaking, they do not delete / do not remove elements from the list: they create a new list and replace the old variable with a new list.
What can be done:
for d in list(records): if d['Price'] == 0: records.remove(d) for d in reversed(records): if d['Price'] == 0: records.remove(d) for idx in range(len(records)-1,-1,-1): if records[idx]['Price'] == 0: records.pop(idx)
I like this one though:
for d in records[::-1]: if d['Price'] == 0: records.remove(d)
source share