How to find minimum value from list that is higher than 0

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 2
Reputation: gdr969 is an unknown quantity at this point 
Solved Threads: 0
gdr969 gdr969 is offline Offline
Newbie Poster

How to find minimum value from list that is higher than 0

 
0
  #1
Oct 25th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 976
Reputation: Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough 
Solved Threads: 222
Gribouillis's Avatar
Gribouillis Gribouillis is offline Offline
Posting Shark
 
2
  #2
Oct 25th, 2009
This should work
  1. value = min(x for x in temperature_sequence if x > 0)
Note: this raises ValueError if all temperatures are below 0.
Last edited by Gribouillis; Oct 25th, 2009 at 7:04 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: gdr969 is an unknown quantity at this point 
Solved Threads: 0
gdr969 gdr969 is offline Offline
Newbie Poster
 
0
  #3
Oct 25th, 2009
tnx a lot, that helped
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC