What is the most efficient way to test for False in a list?

Evan Klitzke evan at yelp.com
Mon Jul 9 03:32:25 CEST 2007


On 7/8/07, lex <alexander.somma at gmail.com> wrote:
> Of course there is the always the iteration method:
>
> list = [1, True, True, False, False, True]
> status = True
> for each in list:
>     status = status and each
>
> but what is your best way to test for for False in a list?

In general, you can just do:

if something in list:
    do_something()

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list