Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41144 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2013-03-12 13:57 -0400 |
| Last post | 2013-03-12 13:57 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Finding the Min for positive and negative in python 3.3 list Terry Reedy <tjreedy@udel.edu> - 2013-03-12 13:57 -0400
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-03-12 13:57 -0400 |
| Subject | Re: Finding the Min for positive and negative in python 3.3 list |
| Message-ID | <mailman.3245.1363111060.2939.python-list@python.org> |
On 3/12/2013 1:03 PM, Norah Jones wrote: > For example: > a=[-15,-30,-10,1,3,5] > > I want to find a negative and a positive minimum. > > example: negative > print(min(a)) = -30 > > positive > print(min(a)) = 1 If this is homework, stop reading and do it yourself ;-) Otherwise... >>> min(i for i in a if i >0) 1 >>> max(i for i in a if i < 0) -10 >>> min(i for i in a if i < 0) -30 You did not specify if you would include 0 in a pos min (0 is neither really positive or negative). -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web