Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python remove duplicates

if mylist:
    mylist.sort()
    last = mylist[-1]
    for i in range(len(mylist)-2, -1, -1):
        if last == mylist[i]:
            del mylist[i]
        else:
            last = mylist[i]
# Quicker if all elements are hashables:
mylist = list(set(mylist))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #remove #duplicates
ADD COMMENT
Topic
Name
8+4 =