I want to find the maximal number of elements contained in a nested dictionary, e.g.
data = {
'violations':
{
'col1': {'err': [elem1, elem2, elem3]},
'col2': {'err': [elem1, elem2]}
}
}
so to find the maximal number of elements in the lists for key 'err' in key 'col1' and 'col2'. Also key 'violations' may contain many keys (e.g. 'col1' , 'col2', 'col3' etc), so what's the best way to do this (using a loop)?
max = 0for col in data.violations:
if max < len(data.violations.col.err):
max = len(data.violations.col.err)