I have program than finds the minimum temperature of every month, but i can't find a way for it to find the minimum temperature that is higher than 0, i can't just use min() cos if the month has temperature that is lower than 0 it is also counted.

Recommended Answers

This should work
[code=python]
value = min(x for x in temperature_sequence if x > 0)
[/code]
Note: this raises ValueError if all temperatures are below 0.

Jump to Post

All 2 Replies

This should work

value = min(x for x in temperature_sequence if x > 0)

Note: this raises ValueError if all temperatures are below 0.

commented: helped with resolving problem +0

tnx a lot, that helped :)