def get_dict_leaves_count(dic): if len(dic) == 0: return 0 else: cnt = 0 for k, v in dic.items(): if not isinstance(v, Mapping): cnt += 1 else: cnt += get_dict_leaves_count(v) return cnt
2023-11-09 20:34:22
def get_dict_leaves_count(dic): if len(dic) == 0: return 0 else: cnt = 0 for k, v in dic.items(): if not isinstance(v, Mapping): cnt += 1 else: cnt += get_dict_leaves_count(v) return cnt