Embarrasing questio

km srikrishnamohan at gmail.com
Thu Feb 12 11:24:02 EST 2009


Hi,

you could do it this way also :

if i in [3,5]:
    do something...

KM
~~~~~~~~~~~~~~~~~~~~~
On Fri, Feb 13, 2009 at 1:19 AM, Michele Simionato <
michele.simionato at gmail.com> wrote:

> On Feb 12, 5:07 pm, TechieInsights <GDoerm... at gmail.com> wrote:
> > On Feb 12, 9:03 am, Catherine Heathcote
> >
> > <catherine.heathc... at gmail.com> wrote:
> > > But I just cant find it. How do I do an or, as in c/c++'s ||? Just
> > > trying to do something simple, the python equivilent of:
> >
> > > if(i % 3 == 0 || i % 5 == 0)
> >
> > > Thanks.
> >
> > in 2.5 and above you can do
> > if any(i%3 == 0, i%5 == 0)
>
> You are missing a few parenthesis: if any([i%3 == 0, i%5 == 0]) (but
> the idiomatic solution is to use or).
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090213/61bad624/attachment-0001.html>


More information about the Python-list mailing list