Find max value in Python 2D list

Asked 2 years ago, Updated 2 years ago, 73 views

list_1 = [(2, 0), (1, 1), (3, 2), (2, 3)]
temp = list_1[0][0]
if temp < max(list_1):

I want to make sure that the values from the two-dimensional list are the highest values in this list Since it is a two-dimensional list, if you use max, the triple is returned, so it cannot be compared with the int value. Is there a way to know max among list_1[*][1] (the first value among all tuples in the list)?

python list max

2022-09-20 19:04

1 Answers

>>> list_1 = [(2, 10), (1, 11), (3, 12), (2, 13)]
>>> max_0th = max(t[0] for t in list_1)
>>> max_0th
3
>>> max_1th = max(t[1] for t in list_1)
>>> max_1th
13
>>> 


2022-09-20 19:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.