Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created May 25, 2020 20:54
Show Gist options
  • Save hsleonis/50b590a5eaa7bc3e4a392c52513fcfc4 to your computer and use it in GitHub Desktop.
Save hsleonis/50b590a5eaa7bc3e4a392c52513fcfc4 to your computer and use it in GitHub Desktop.
Returns True if all the values in a list are unique, False otherwise.
def all_unique(lst):
  return len(lst) == len(set(lst))
x = [1, 2, 3, 4, 5, 6]
y = [1, 2, 2, 3, 4, 5]
all_unique(x) # True
all_unique(y) # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment