What's the best way to delete dictionary items? I have a dictionary with tuples as keys, and I would like to delete all keys with a certain element. First I wrote: for item in td.data.keys(): if item[attr] != value: del td.data[item] But will this work?