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

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.