Skip to content

Instantly share code, notes, and snippets.

@poros
Created October 4, 2015 13:33
Show Gist options
  • Save poros/193b17776fb08545b3bf to your computer and use it in GitHub Desktop.
Save poros/193b17776fb08545b3bf to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment