I am trying to create a function that returns a unique value on a python list. So for example:
List = [1,1,1,1,2,1,1,1,1,]
How would I go about returning the unique value, 2.
I have tried the following:
import numpy as np
def find_uniq(arr):
abc = np.array(arr)
return list(np.unique(abc))
However when I try this ^^^ , it returns (2) two values , the 1 and the 2. Since they are both unique values to the list. Though I only want the 2.
countmethod for each unique value and return the element with count equal to 1.Counterobject from thecollectionsmodule