poros
10/4/2015 - 1:33 PM

Check if every elements satisfies a condition

Check if every elements satisfies a condition

for x in numbers:
    if x % 2 != 0:
        return False
return True

all(x % 2 == 0 for x in numbers)
# it's a generator, stops at the first occurrence