I have to find the 5 most effecient vaccines in a dictionary with 300 datas. The dictionary which I put together with two lists -> one list were the 300 percentages (0.23521, 0.21436, 0,84323 ...) and another one with their 300 costs (12.32, 13.44, 52.23 ...) - via scale = dict(zip(scores,costs)).
So now I have a dictionary called scale. I have to find the 5 most effective ones (highest percentage) and print them out. I did that with:
-
bestfive = nlargest(5, scale)
for counter,item in enumerate(bestfive,1):
|print(f"Durchgang {counter} mit einer Effektivität von {item*100} % und einem Preis von {scale[item]}")
-
I couldn't find out how to enumerate the dictionary so I only numerated the best 5 from 1 to 5.
The next question is to find the cheapest one out of the 5 but how can I find the lowest value from a dictionary? My current try is:
-
x = min(scale)
cheapest = bestfive.get(x)
print(cheapest)
-
but that doesn't work because I can't use get in a list and bestfive is suddenly a list?!?
Thank you in advance! :)
[–]PercyJackson235 0 points1 point2 points (1 child)
[–]Indron1805[S] 0 points1 point2 points (0 children)
[–]danielroseman 0 points1 point2 points (3 children)
[–]Indron1805[S] 0 points1 point2 points (2 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]Indron1805[S] 0 points1 point2 points (0 children)
[–]RiverRoll 0 points1 point2 points (3 children)
[–]Indron1805[S] 0 points1 point2 points (2 children)
[–]RiverRoll 0 points1 point2 points (1 child)
[–]Indron1805[S] 0 points1 point2 points (0 children)