Remove duplicate elements in a list

0 votes
What is the quickest way to remove duplicate elements in a list?
May 11, 2018 in Python by kaalabilli
• 1,090 points
837 views

1 answer to this question.

0 votes

Here is the code for this -

list(set((list_of_numbers)

For example,

>>> l = [1,1,1]
>>> l
[1, 1, 1]
>>> set(l)
{1}

Now, convert the set back to a list. The obtained list will contain no duplicate elements.

answered May 12, 2018 by Hamartia's Mask
• 1,580 points

Related Questions In Python

0 votes
1 answer

How to remove the duplicate values in a list?

a = [10,20,30,40,10,20,30,40,30,40,50,60] s = set(a) c = list(s) print(c) this ...READ MORE

answered Mar 20, 2019 in Python by Mohammad
• 3,230 points
771 views
0 votes
1 answer

Adding elements to a list in python

Use extend() instead: l = [5, 7, 12, ...READ MORE

answered Apr 23, 2018 in Python by Nietzsche's daemon
• 4,260 points
774 views
+1 vote
3 answers

How can I remove duplicate dict in list in Python?

[dict(t) for t in {tuple(d.items()) for d ...READ MORE

answered Aug 15, 2019 in Python by anonymous

edited Aug 20, 2019 by Kalgi 9,254 views
0 votes
1 answer

How to count the number of elements in a list?

To count the number of elements of ...READ MORE

answered May 27, 2019 in Python by Nisa
• 1,090 points
5,187 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,363 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,934 views
0 votes
1 answer

Deleting a list element by value

Use the remove() function: >>> p = [1, ...READ MORE

answered May 12, 2018 in Python by Hamartia's Mask
• 1,580 points
577 views
0 votes
1 answer

Remove a string suffix

You can remove the substring using slicing. ...READ MORE

answered Jun 7, 2018 in Python by Hamartia's Mask
• 1,580 points
950 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP