I want to iterate a dictionary, examine the value and delete items that matches certain values.
Example
d = {1, 1, 2, 1, 4, 5}
for i in d:
if i == 1:
del i
But we know doing this is dangerous since the list is updated while it is been iterated. What is clean way of doing this in Python?
If
kis your dictionary, you can doFor 2.7+ and 3.0
For anything older, you can do