I have a dict, { "foo": set(["a", "b"]), "bar": set(["c", "d"]) }
, and I'm given an element of one of the two sets and the name of the other set. I need to remove that element. How would I go about doing this? My best attempt so far is this:
keys = dict.keys()
if Element in dict[keys[0]].union(dict[keys[1]]):
dict[keys[abs(keys.index(Other_Set) - 1)]].remove(Element)
This seems to be a bit excessive, though; is there any way I can improve it?