I have this code:
vals = [(1,3,5),(2,2,5),(1,2,6)]
max(vals ,key=itemgetter(1))[2]
My question is: why does it return 5 instead of 6 ? I need the maximum value of the last element. If I take max(...)[0] it gives 2, if I take max(...)[1] it gives 3, but if I take max(...)[2] it gives 5. Why is this?