Find Unique Elements of a List

In this tutorial, we will learn how to retrieve a list of unique elements in a list.

Let us use the list A = [2,2,5,6,8,10,3]

I want to find out the what are the unique elements of A

In python, the easiest way to do it is to convert the list to a set and convert it back it a list.

The syntax is Unique_of_A = list(set(A))

Unique_of_A must equal [2,5,6,810,3]

Let us try it in the python interpreter



This post was inspired by a tutorial at http://mattdickenson.com/2011/12/31/find-unique-values-in-list-python/