30 seconds of python

  Back to Home

all_unique

listbeginner

Returns True if all the values in a flat list are unique, False otherwise.

Use set() on the given list to remove duplicates, compare its length with the length of the list.

def all_unique(lst):
  return len(lst) == len(set(lst))