I like following a "hit list" approach where you iterate through the dictionary, then add the ones you want to delete to a list, then after iterating, delete the entries from that list like so:
hitList =[]
for dictEntry: if test condition, hitList.append
for entry in hitList:
delete dict[entry]
this is just some pseudocode but i've been successful with this in the past