How to find maximum value in nested list with Python

2 Answers

0 votes
lst = [ [3, 0.0011], [7, 0.0012], [3, 0.0015], [5, 0.0013] ]

first_value, max_value = max(lst, key=lambda item: item[1])

print(max_value)
print(first_value)  





'''
run:

0.0015
3

'''

 



answered Apr 19, 2021 by avibootz
0 votes
lst = [ [3, 0.0011], [7, 0.0012], [3, 0.0015], [5, 0.0013] ]

max_value, second_value = max(lst, key=lambda item: item[0])

print(max_value)
print(second_value)  





'''
run:

7
0.0012

'''

 



answered Apr 19, 2021 by avibootz
...