Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created May 25, 2020 20:48
Show Gist options
  • Save hsleonis/647a1ec8d6c5028b404251643dd31c10 to your computer and use it in GitHub Desktop.
Save hsleonis/647a1ec8d6c5028b404251643dd31c10 to your computer and use it in GitHub Desktop.
Checks if all elements in a list are equal.
def all_equal(lst):
  return lst[1:] == lst[:-1]
all_equal([1, 2, 3, 4, 5, 6]) # False
all_equal([1, 1, 1, 1]) # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment