Reputation: 15
How do I find the max for each tuple.
lst1 = [(4, 1, 9, 22, 6, 14),( 7, 22, 9, 2, 1, 2 )]
lst2 = map(max, zip(*lst1))
print(lst2)
Upvotes: 0
Views: 37
Reputation: 86326
In Python 3:
In [1]: lst1 = [(4, 1, 9, 22, 6, 14),( 7, 22, 9, 2, 1, 2 )]
In [8]: tuple(map(max, lst1))
Out[8]: (22, 22)
Upvotes: 1