MathsGee is free of annoying ads. We want to keep it like this. You can help with your DONATION

0 like 0 dislike
5 views

How will you remove the duplicate elements from the given list?

words = [‘one’, ‘one’, ‘two’, ‘three’, ‘three’, ‘two’]

| 5 views

0 like 0 dislike

A simple solution is to iterate over the list, identify duplicates and remove them.

But the best solution which we can recommend is as follows.

a = [1,2,2,3]
list(set(a))

The set is another type available in Python. It doesn’t allow copies and provides some good functions to perform set operations like union, difference etc.

by Wooden (3,474 points)

0 like 0 dislike
0 like 0 dislike
0 like 0 dislike