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

Y

Yves Pouplard

Diez B. Roggisch said:
but what is your best way to test for for False in a list? [...]
status = all(list)
Am I mistaken, or is this no identity test for False at all?

You are mistaken.
all take an iterable and returns if each value of it is true.

Testing for truth is not the same as an identity test for False. OP's
message doesn't make it clear which one he's looking for. This
illustrates the difference:
False in [3, 2, 1, 0, -1]
True # no False here

I rather think 'True' means 'yes, I have found False here' ...
all([3, 2, 1, 0, -1])
False # false value present, not necessarily False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top