Data={
0:{
'country_two': "3",
'country_one': "5",
'med_dict':{
0: {
'endDate': "732",
'endTime': "89",
}
},
},
1: {
'country_four': "2",
'country_three': "90",
'med_dict': {
0: {
'endDate': "245",
'endTime': "222",
}
},
}
}
I want to retrieve the maximum value for med_dict['endDate'] in this above dictionary. How to retrieve data in such dictionary for specific key like 'med_dict'?
CodePudding user response:
Try to start with something like this: (skip last step on purpose, it's for you to get it, which is super straightforward) ;-)
for k in Data:
print(Data[k]['med_dict'][0]['endDate'])
CodePudding user response:
maxVal = Data.get(0).get('med_dict').get(0).get('endDate')
I would simplify that dictionary. Way too overly complicated.