if I have the following:
[{'place':1, 'acc':75}, {'place':2, 'acc':95}, {'place':3, 'acc':60}]
What would be the best way to get the value of the place which has the best accuracy ?
In this example the result would be: 2
>Solution :
The built-in max function allows you to specify a key. So, for your example, you could do this:
list_ = [{'place':1, 'acc':75}, {'place':2, 'acc':95}, {'place':3, 'acc':60}]
print(max(list_, key=lambda x: x['acc'])['place'])
Output:
2