Write a program to find the duplicates in a list?



Write a program to find the duplicates in a list?..

Answer / Amit Kumar Giri

Here's a Python program that finds duplicates in a list:nn```pythonnlst = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8]ndups = set(lst) # convert list to set to remove duplicatesndups -= set(lst) # find the difference between the original set and the converted set. This gives us the duplicates.nprint(list(dups))```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

What is python unit test?

1 Answers  


Should I use single or double quotes in python?

1 Answers  


Do sheeps sleep?

1 Answers  


Does python have polymorphism?

1 Answers  


Explain the use of the ‘nonlocal’ keyword in python?

1 Answers  


What is python used for at google?

1 Answers  


What is none python?

1 Answers  


How is Multithreading achieved in Python?

1 Answers  


What are the tools that help to find bugs or perform the static analysis?

1 Answers  


What are the differences between the threading and multiprocessing in python?

1 Answers  


Explain the difference between append vs extend in list?

1 Answers  


Explain how can you access a module written in python from c?

1 Answers  


Categories