A good way to check whether a python object is an instance of a type is to use isinstance()
which is Python's 'built-in' function.
For Python 3.6:
dct = {
"1": "a",
"3": "b",
"8": {
"12": "c",
"25": "d"
}
}
for key in dct.keys():
if isinstance(dct[key], dict)== False:
print(key, dct[key])
#shows:
# 1 a
# 3 b