paul.hankin at gmail.com
Wed Oct 3 09:34:17 CEST 2007
On Oct 2, 11:09 pm, Paul McGuire <pt... at austin.rr.com> wrote:
> On Oct 2, 4:20 pm, Paul Hankin <paul.han... at gmail.com> wrote:
> > On Oct 2, 10:06 pm, brad <byte8b... at gmail.com> wrote:
> > > How is this expressed in Python?
> > > If x is in y more than three times:
> > > print x
> > > y is a Python list.
> > Or the slightly-too-flashy version:
> > if sum(1 for a in y if x == a) > 3:
> > print x
> As long as you are eschewing count for sum, don't forget that true is
> 1 and false is 0:
> if sum(x==a for a in y) > 3:
> print x
I like it!
More information about the Python-list