I don't remember if it applies to dicts or not, but in general it's not a good idea to modify the thing that you're iterating through.  Instead, accumulate the items to remove into a secondary list, then use that after the loop to remove the items.