alist = [(1,3),(2,5),(2,4),(7,5)]
I need to get the min max value for each position in tuple.
Fox example: The exepected output of alist is
min_x = 1
max_x = 7
min_y = 3
max_y = 5
Is there any easy way to do?
alist = [(1,3),(2,5),(2,4),(7,5)]
I need to get the min max value for each position in tuple.
Fox example: The exepected output of alist is
min_x = 1
max_x = 7
min_y = 3
max_y = 5
Is there any easy way to do?
For python 3:
alist = [(1,3),(2,5),(2,4),(7,5)]
[x_range, y_range] = list(zip(map(min, *test_list), map(max, *alist)))
print(x_range, y_range) #prints: (1, 7) (3, 5)
Since zip/map returns an iterator <object at 0x00> you need to use list()