Issue
how to get only the par details from below nested dict. Requirement is to get only the par values from the below input. expected output to have only the parent values
a = {
'a0': {
'sub_int': {
1: {
'name': 'xe-0/0/0:1',
'par': 'xe-0/0/0',
},
2: {
'name': 'xe-1/0/0:2',
'par': 'xe-1/0/0',
},
3: {
'name': 'xe-0/0/0:2',
'par': 'xe-0/0/0',
},
},
},
'a1': {
'sub_int': {
1: {
'name': 'xe-0/0/0:1',
'par': 'xe-0/0/0',
},
2: {
'name': 'xe-1/0/0:2',
'par': 'xe-1/0/0',
},
3: {
'name': 'xe-0/0/0:2',
'par': 'xe-0/0/0',
},
},
},
}
Solution
Try this:
for my_dict in a:
for my_dict_inner in a[my_dict]['sub_int']:
print(a[my_dict]['sub_int'][my_dict_inner]['par'])
Answered By - Avinash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.