def recursive_items(dictionary):
for key, value in dictionary.items():
if type(value) is dict:
yield from recursive_items(value)
else:
yield (key, value)
a = {'a': {1: {1: 2, 3: 4}, 2: {5: 6}}}
for key, value in recursive_items(a):
print(key, value)
example_dict.get('key1', {}).get('key2')
D = {'emp1': {'name': 'Bob', 'job': 'Mgr'},
'emp2': {'name': 'Kim', 'job': 'Dev'},
'emp3': {'name': 'Sam', 'job': 'Dev'}}
print(D['emp1']['name'])
# Prints Bob
print(D['emp2']['job'])
# Prints Dev
for account in bank_dictionary:
print("
ACCOUNT: ", account)
for subaccount in bank_dictionary[account]:
print("
Subaccount: ", subaccount)