Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: getting lowest integer in list of tuples

My current plan is to determine which is the first entry in a number of Tkinter listboxes highlighted using .curselection() and combining all of the resulting tuples into a list, producing this:

tupleList = [(), (), ('24', '25', '26', '27'), (), (), (), ()]

I'm wondering as to how to determine the lowest integer. Using .min(tupleList) returns only (), being the lowest entry in the list, but I'm looking for a method that would return 24.

What's the right way to get the lowest integer in any tuple in the list?

like image 927
Kryptonite Avatar asked Mar 01 '26 01:03

Kryptonite


1 Answers

>>> nums = [(), (), ('24', '25', '26', '27'), (), (), (), ()]
>>> min(int(j) for i in nums for j in i)
24
like image 180
John La Rooy Avatar answered Mar 03 '26 13:03

John La Rooy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!