Last active
March 11, 2016 08:36
-
-
Save minstrel271/08c79fa58d315d690b3e to your computer and use it in GitHub Desktop.
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 all_equal(iterable): | |
""" | |
Check if all items are equal to each other. | |
>>> all_equal([1, 1, 1]) | |
True | |
>>> all_equal([1, 2, 1]) | |
False | |
Args: | |
iterable (iterable): a series of items to be checked | |
""" | |
return len(set(iterable)) <= 1 | |
if __name__ == '__main__': | |
import doctest | |
doctest.testmod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment