Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Created December 24, 2015 11:08
Show Gist options
  • Save dboyliao/6de38f45301e417bfb55 to your computer and use it in GitHub Desktop.
Save dboyliao/6de38f45301e417bfb55 to your computer and use it in GitHub Desktop.
l = [[1,2,3,4,5], [5,6,7,50], [10,20,30]]
i_max, (j_max, v_max) = max(enumerate([max(enumerate(ll), key = lambda t: t[1]) for ll in l]), key = lambda t: t[1][1])
# >>> i_max = 1, j_max = 3, v_max = 50
@dboyliao
Copy link
Author

Then you can find the maximum by l[i_max][j_max] which will gives you 50 in this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment