I have an array. The valid values are not zero (either positive or negetive). I want to find the minimum and maximum within the array which should not take zeros into accoun
You could use a generator expression to filter out the zeros:
array = [-2, 0, -4, 0, -3, -2] max(x for x in array if x != 0)