-2

Can someone tell why the following result is true. all(2%p>0 for p in set()) I know that am empty set is false. I cannot understand why the remain after divided by a empty set is greater than zero.

  • 6
    Documentation for `all`: `Return True if all elements of the iterable are true (or if the iterable is empty).`. If the set is empty, the created iterable won't have any elements. – Carcigenicate Apr 09 '20 at 17:18

1 Answers1

0

all returns True if it's applied on an empty iterable. set() creates a new empty set, so calling all on any permutation on it, will return True.

Mureinik
  • 297,002
  • 52
  • 306
  • 350