question 313 Iterators & Generators · easy
The first reading over the limit
A heat alert needs the first daily maximum above a limit, from a station file that may cover decades. Write first_above(readings, limit): return the first reading strictly greater than limit, or None if there is none, and stop reading as soon as it is found.
Function
first_above(readings, limit)Returnsthe first reading
> limit, or NoneLazytake no more readings than needed
Examples
callfirst_above([31.7, 33.9, 36.1, 30.6, 38.3], 35)returns36.1
callfirst_above([18.3, 19.4], 25)returnsNone
callfirst_above([40.2, 12], 35)returns40.2