To get the unique elements from a list in python you can use the built in
lst = [1, 2, 1, 3, 4, 3, 4, 5, 5]
[1, 2, 3, 4, 5]
Though note that
set() does not return a list but a “set” object, for most purposes you will need to convert it to a list in order to work with it, as done above.
It may be important to note that
set() does not guarantee order of elements so
set() may not be the way to go. In this event you could use a looping method. Say you have a function that takes a
lst as input, and creates an empty list to hold the result. Then loop through the input and for every value check if it is in the result list, if it is not
.append() it. Finally return the result.
result = 
for i in lst:
if i not in result: