On Thu, Jan 22, 2009 at 11:35 AM, blueiur wrote:
> i think it's best way
> lst = [0, 1, 3.14, 20, 8, 8, 3.14]
> len( filter(lambda x: x > 3.13 and x < 3.15, lst) )
> 2
I prefer this way (cleaner):
>>> lst = [0, 1, 3.14, 20, 8, 8, 3.14]
>>> len([x for x in lst if 3.13 < x < 3.15])
2
>>>
cheers
J
i think it's best way
lst = [0, 1, 3.14, 20, 8, 8, 3.14]
len( filter(lambda x: x > 3.13 and x < 3.15, lst) )
2
On 1월22일, 오전6시53분, culpritNr1 wrote:
> Hello All,
>
> Say I have a list like this:
>
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's
culpritNr1 wrote:
Thank you Fogelbird and Jeff.
I actually tried to find out if such function existed. I did
help("count")
no Python documentation found for 'count'
[snip]
'count' is a method of the list class, so you need:
help(list.count)
and if you want help on the list class then it's
On Jan 21, 5:22 pm, culpritNr1 wrote:
> Thank you Fogelbird and Jeff.
>
> I actually tried to find out if such function existed. I did
>
> >>> help("count")
>
> no Python documentation found for 'count'
>
> Anyway. More than counting, I am interested in list subsetting in a simple
> way. Forget ab
culpritNr1 wrote:
Thank you Fogelbird and Jeff.
I actually tried to find out if such function existed. I did
help("count")
no Python documentation found for 'count'
Anyway. More than counting, I am interested in list subsetting in a simple
way. Forget about counting. Say I have a list of lis
culpritNr1 writes:
> Anyway. More than counting, I am interested in list subsetting in a simple
> way. Forget about counting. Say I have a list of lists and I want to pull
> only the rows where the second "column" equals 3.14.
list_of_lists = [[1.414,2.718,3.14],[4.00,3.14,1.618],[72,29,39]]
thos
Thank you Fogelbird and Jeff.
I actually tried to find out if such function existed. I did
>>> help("count")
no Python documentation found for 'count'
Anyway. More than counting, I am interested in list subsetting in a simple
way. Forget about counting. Say I have a list of lists and I want to
On Thu, Jan 22, 2009 at 9:09 AM, Jeff McNeil wrote:
> On Jan 21, 4:53 pm, culpritNr1 wrote:
> > Hello All,
> >
> > Say I have a list like this:
> >
> > a = [0 , 1, 3.14, 20, 8, 8, 3.14]
> >
> > Is there a simple python way to count the number of 3.14's in the list in
> > one statement?
> >
> > I
culpritNr1 writes:
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's in the list in
> one statement?
n = sum(1 for x in a if x == 3.14)
--
http://mail.python.org/mailman/listinfo/python-list
culpritNr1 wrote in
news:[email protected] in
comp.lang.python:
>
> Hello All,
>
> Say I have a list like this:
>
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's in the list
> in one statement?
>
> In R I do
FogleBird:
> a.count(3.14)
If the values to count are approximated FP values, then you may need
something more complex, like:
leniter(ifilter(somefunction, a))
Where somefunction uses an approximated comparison, and leniter is
just a function that counts the items of a generic iterator.
Bye,
be
On Jan 21, 4:53 pm, culpritNr1 wrote:
> Hello All,
>
> Say I have a list like this:
>
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's in the list in
> one statement?
>
> In R I do like this
>
> a = c(0 , 1, 3.14, 20, 8, 8, 3.14)
>
> length( a[ a[]
On Jan 21, 4:53 pm, culpritNr1 wrote:
> Hello All,
>
> Say I have a list like this:
>
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's in the list in
> one statement?
>
> In R I do like this
>
> a = c(0 , 1, 3.14, 20, 8, 8, 3.14)
>
> length( a[ a[]
13 matches
Mail list logo