I have a dictionary like this:
a = {"a": "b", "c": "d", {"e": "E", "f": "F"}}
and I want to convert it to:
b = {"a": "b", "c": "d", "e": "E", "f": "F"}
I have a dictionary like this:
a = {"a": "b", "c": "d", {"e": "E", "f": "F"}}
and I want to convert it to:
b = {"a": "b", "c": "d", "e": "E", "f": "F"}
First your dict is not valid, it should be always a key value pair. Below it is what should be case for your dict
a = {"a": "b", "c": "d", 'something':{"e": "E", "f": "F"}}def func(dic):re ={}for k,v in dic.items():if isinstance(v, dict):re.update(v)else:re.update({k:v})return reprint(func(a))
output
{'a': 'b', 'c': 'd', 'e': 'E', 'f': 'F'}