Created
July 6, 2019 06:55
-
-
Save eyaltrabelsi/7fc11068d55c560deaff1006ff1b1b03 to your computer and use it in GitHub Desktop.
Python trick Finding the index of the min/max item in an iterable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = [2, 3, 1] | |
>>> min(enumerate(a),key=lambda x: x[1])[0] | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment