👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

In Python, how to remove duplicates from lists ?

The best option to remove duplicates from a list is to convert the list in set (which cannot contain duplicate), then to convert back to list:

myList = [5, 1, 1, 2, 5, 6, 3, 4, 4, 4, 2]
# list -> set -> list
myList = list(set(myList))
# [1, 2, 3, 4, 5, 6]
print (myList)

Set if one of the 4 built-in data types in Python used to store collections of data, the other 3 are ListTuple, and Dictionary, all with different qualities and usage.

More