Skip to content

Get unique elements from a list in Python

Advertisements
def removeDuplicates(li):
  return list(set(li))
print(removeDuplicates([1, 2, 2, 1, 2, 3, 4, 3])) 
# [1, 2, 3, 4]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.