Created
October 4, 2015 13:33
-
-
Save poros/193b17776fb08545b3bf to your computer and use it in GitHub Desktop.
Check if every elements satisfies a condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment