Skip to content

Instantly share code, notes, and snippets.

@minstrel271
Last active March 11, 2016 08:36
Show Gist options
  • Save minstrel271/08c79fa58d315d690b3e to your computer and use it in GitHub Desktop.
Save minstrel271/08c79fa58d315d690b3e to your computer and use it in GitHub Desktop.
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