python - Finding the minimum and maximum of a list of arrays -


let's have 2 arrays inside single array, like:

main_array = [[1, 2, 3, 4], [4, 5, 6, 7]] 

i find min , max of each of arrays , store them in single array. above be:

result = [1, 4, 4, 7] 

how use python's inbuilt min() , max() in case?

i tried min(main_array) , max(main_array) giving me:

result = [1,7] 

you can use min() or max() on single list it's min/max value. can use list comprehension loop through lists in list , functions want use:

main_array = [[1,2,3,4], [4,5,6,7]]     res = [func(l) l in main_array func in (min, max)]     print(res) 

Comments