[Solved] How to compare number of values in a dictionary [closed]

[ad_1]

Assuming you have an input that looks like this:dic={x:[a,b],y:[c]}. Try this,

res=sorted([(x,len(dic[x])) for x in dic],key=lambda x:x[0])

[ad_2]

solved How to compare number of values in a dictionary [closed]