Get Help And Discuss STEM Concepts From Math To Data Science & Financial Literacy

Help The Education Support Forum through MathsGee serve learners across Africa with a DONATION

0 like 0 dislike
4 views

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

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

 

in Data Science by Wooden (3.0k points) | 4 views

1 Answer

0 like 0 dislike
Best answer

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.0k points)

Welcome to MathsGee Q&A Bank, Africa’s largest personalized STEM and Financial Literacy education network that helps people find answers to problems, connect with others and take action to improve their outcomes.


MathsGee Q&A is the STEM and Financial Literacy knowledge-sharing community where students and experts put their heads together to crack their toughest questions.


Help The Education Support Forum through MathsGee serve learners across Africa with a DONATION

Enter your email address: