Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41142 > unrolled thread

Re: Finding the Min for positive and negative in python 3.3 list

Started byWolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de>
First post2013-03-12 17:48 +0000
Last post2013-03-12 17:48 +0000
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.


Contents

  Re: Finding the Min for positive and negative in python 3.3 list Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-12 17:48 +0000

#41142 — Re: Finding the Min for positive and negative in python 3.3 list

FromWolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de>
Date2013-03-12 17:48 +0000
SubjectRe: Finding the Min for positive and negative in python 3.3 list
Message-ID<mailman.3243.1363110535.2939.python-list@python.org>
Norah Jones <nh.jones01 <at> gmail.com> writes:

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

try this:
min(a)   => -30
min([n for n in a if i>0])   => 1

of course, you have to figure out what you want to do with a zero value.





[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web