Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    Simplification: Change all(v for v in l) to just all(l); no need to make a special generator expression when all can process the list directly. Commented Feb 3, 2016 at 3:13
  • 4
    Also, you inverted all and any; all tells you if all the results were non-empty, not if it has non-empty elements,and any says if it has non-empty elements (it could still have empty, but if any returns True, at least one was non-empty). any is probably more useful here. Commented Feb 3, 2016 at 3:17
  • It does not work if the elements contains value False, sample all([1, 2, 3, False]), False returns as result. Commented Mar 27, 2018 at 2:54
  • @Ivan that does what it is supposed to do. Since they all don't have a Truthy value it returns False. Commented Mar 27, 2018 at 6:34