Optimal method to find the max of sublist items within list

Just use max with a generator expression:

>>> lst = [[1, 2, 3], [2, 4, 2], [0, 1, 1]]
>>> max(l[2] for l in lst)
3

Also, don’t name your variables list, you are shadowing the type.

Leave a Comment