- I have a dictionary with key-value pairs like
{a : (b,c,d,e)}. - If i encounter a tuple
(b,c,d,e), i want to lookup in dictionary, the key having the same tuple as a value and delete that key from the dictionary. Can it be done like this in python?
I have a dictionary with key-value pairs like {a : (b,c,d,e)} . If i
Share
use
list(),set(), ortuple()becauselist(dict)ortuple(dict)orset(dict)returns the keys of a dictionary and you can iterate over these returned keys and pop items from the dictionary,And as Lattyware suggested ,to stop the iteration after removal of one value use
breakstatement afterpop().