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])
solved How to compare number of values in a dictionary [closed]
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])
solved How to compare number of values in a dictionary [closed]