Created
December 15, 2011 19:46
-
-
Save tanelpuhu/1482536 to your computer and use it in GitHub Desktop.
has_falsy
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
def has_falsy(lst): | |
def is_falsy(val): | |
return not val | |
return not not len(filter(is_falsy, lst)) | |
assert not has_falsy([]) | |
assert not has_falsy([1,2,3]) | |
assert not has_falsy(['0']) | |
assert not has_falsy(['None']) | |
assert has_falsy([None]) | |
assert has_falsy([0]) | |
assert has_falsy([False]) | |
assert has_falsy([False,1,2,3]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment