Timeline for Getting key with maximum value in dictionary?
Current License: CC BY-SA 4.0
Post Revisions
40 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 3, 2023 at 7:32 | comment | added | Sumanth Vakacharla | This inverse = [(value, key) for key, value in stats.items()] print(max(inverse)[1]) has a limitation that it will only return one key when there are maximum value duplicates. For example, stats = {'a': 1, 'b': 3000, 'c': 3000} will only return 'c' if the requirement is to return ['b','c'] | |
| Aug 22, 2022 at 2:27 | answer | added | Allan | timeline score: 2 | |
| Apr 9, 2022 at 9:53 | history | edited | Mateen Ulhaq | CC BY-SA 4.0 |
Shorten.
|
| Mar 29, 2022 at 9:20 | history | edited | Francisco | CC BY-SA 4.0 |
added 3 characters in body
|
| Sep 18, 2021 at 19:21 | answer | added | Ashutosh | timeline score: 5 | |
| Sep 18, 2021 at 18:37 | answer | added | BusBar_යසස් | timeline score: 1 | |
| Apr 2, 2021 at 20:10 | answer | added | Shaonsani | timeline score: 2 | |
| Sep 4, 2020 at 16:36 | answer | added | Bhindi | timeline score: 38 | |
| Jun 2, 2020 at 13:00 | answer | added | Ali Sajjad Rizavi | timeline score: 11 | |
| Feb 14, 2020 at 17:22 | answer | added | pk786 | timeline score: 159 | |
| Feb 14, 2020 at 4:00 | answer | added | wkzhu | timeline score: 4 | |
| Feb 13, 2020 at 13:58 | answer | added | Ignacio Alorre | timeline score: 1 | |
| Aug 19, 2019 at 15:35 | answer | added | kslote1 | timeline score: 16 | |
| Nov 1, 2018 at 11:05 | answer | added | jpp | timeline score: 8 | |
| Sep 12, 2018 at 9:43 | answer | added | ron_g | timeline score: 12 | |
| Aug 23, 2018 at 4:08 | answer | added | leo022 | timeline score: 76 | |
| May 4, 2018 at 6:50 | answer | added | priya khokher | timeline score: 20 | |
| Jan 10, 2018 at 5:32 | answer | added | Jasha | timeline score: 5 | |
| Jan 6, 2018 at 11:59 | comment | added | Atcold |
max(stats) will use the labels as keys (it will return 'c', given that's the maximum label), max(stats, key=lambda key: stats[key]) is what OP was after (which will return 'b', label of maximal indexed value). Is it any clearer?
|
|
| Dec 17, 2017 at 11:28 | answer | added | Karim Sonbol | timeline score: 26 | |
| Dec 13, 2017 at 10:22 | comment | added | John Red |
Um, what's wrong with max(stats)?
|
|
| Sep 5, 2017 at 15:18 | review | Suggested edits | |||
| Sep 5, 2017 at 16:30 | |||||
| Sep 4, 2017 at 20:34 | answer | added | user2399453 | timeline score: 1 | |
| Jul 11, 2017 at 12:50 | answer | added | ragardner | timeline score: 2 | |
| May 20, 2017 at 17:11 | answer | added | Woooody Amadeus | timeline score: 2 | |
| Feb 23, 2016 at 18:58 | answer | added | ukrutt | timeline score: 12 | |
| Feb 7, 2016 at 17:31 | answer | added | I159 | timeline score: 82 | |
| May 5, 2015 at 2:03 | answer | added | watsonic | timeline score: 13 | |
| May 2, 2014 at 13:07 | answer | added | Climbs_lika_Spyder | timeline score: 35 | |
| Jun 20, 2013 at 15:32 | answer | added | Erika Sawajiri | timeline score: 2 | |
| S May 29, 2013 at 11:39 | history | suggested | Darshana | CC BY-SA 3.0 |
improve formatting
|
| May 29, 2013 at 11:36 | review | Suggested edits | |||
| S May 29, 2013 at 11:39 | |||||
| Apr 11, 2013 at 5:14 | history | protected | jamylak | ||
| Sep 9, 2012 at 23:30 | answer | added | the wolf | timeline score: 273 | |
| Nov 11, 2008 at 6:24 | answer | added | A. Coady | timeline score: 2106 | |
| Nov 7, 2008 at 14:41 | answer | added | Tim Ottinger | timeline score: 43 | |
| Nov 6, 2008 at 13:50 | vote | accept | ricafeal | ||
| Nov 6, 2008 at 11:28 | answer | added | unbeknown | timeline score: 53 | |
| Nov 6, 2008 at 10:58 | answer | added | unbeknown | timeline score: 776 | |
| Nov 6, 2008 at 10:49 | history | asked | ricafeal | CC BY-SA 2.5 |