Let's say I have a dictionary called my_dic:
my_dict = {'a': {'spam': {'foo': None, 'bar': None, 'baz': None},'eggs': None}, 'b': {'ham': None}}
Then if I input spam
, it should return a
, and if I input bar
it should return spam
. If I input b
, it should return None
. Basically getting the parent of the dictionary.
How would I go about doing this?