Simple, self-explanatory code snippets.
l = [1,2,3,4,4,5,5,5,6,1]
duplicates = list(set([x for x in l if l.count(x) > 1]))
for d in duplicates:
l.remove(d)
print(l)
No comments:
Post a Comment