How can I make a function to return the lowest number in a list like:
listA = [[10,20,30],[40,50,60],[70,80,90]]
I want it to return 10
How can I make a function to return the lowest number in a list like:
listA = [[10,20,30],[40,50,60],[70,80,90]]
I want it to return 10
Flatten the list by using itertools.chain, then find the minimum as you would otherwise:
from itertools import chain
listA = [[10,20,30],[40,50,60],[70,80,90]]
min(chain.from_iterable(listA))
# 10
 
    
    >>> listA = [[10,20,30],[40,50,60],[70,80,90]]
>>> min(y for x in listA for y in x)
10
 
    
    Set result to float("inf"). Iterate over every number in every list and call each number i. If i is less than result, result = i. Once you're done, result will contain the lowest value.
 
    
    This is possible using list comprehension
>>> listA = [[10,20,30],[40,50,60],[70,80,90]]
>>> output = [y for x in listA for y in x]
>>> min(output)
10
