我有以下字典:
Counter({'L': 233, 'T': 208, 'I': 169, 'G': 167, 'V': 161, 'N': 155, 'R': 151, 'S': 149, 'K': 148, 'E': 146, 'A': 144, 'Q': 131, 'P': 97, 'D': 92, 'W': 92, 'Y': 85, 'C': 80, 'F': 78, 'M': 52, 'H': 44})
现在我想对它进行一些计数。但是它还不能工作。我想从最高的3个和最低的3个值中得出总和的百分比。然后我想这样打印:
print("number 1 is:", <highestvalue>, "with this %:", <%fromhighestvalue>)
我有总和以将其转换为百分比,但由于字典未列出,因此他使用错误的值进行计数。我现在对最高值有以下内容:def most(total, som):
a = som[list(som)[0]]
b = som[list(som)[1]]
c = som[list(som)[2]]
first = (a*100)/total
seccond = (b*100)/total
third = (c*100)/total
firstKey = list(som.keys())[list(som.values()).index(a)]
seccondKey = list(som.keys())[list(som.values()).index(b)]
thirdKey = list(som.keys())[list(som.values()).index(c)]
return first, seccond, third, firstKey, seccondKey, thirdKey`
请问有人能帮我解决这个问题吗?
现在的结果是这样的:
first: F Procentaantal: 3.020914020139427
seccond: R Procentaantal: 5.848179705654531
third: D Procentaantal: 3.563129357087529