Given a list of integers with duplicate elements in it. The task to generate another list, which contains only the duplicate elements. In simple words, the new list should contain the elements which appear more than one.
Input : list = [10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20] Output : output_list = [20, 30, -20, 60] Input : list = [-1, 1, -1, 8] Output : output_list = [-1]
Below is the implementation :
[20, 30, -20, 60]
- Program to print N minimum elements from list of integers
- Python | Program to count duplicates in a list of tuples
- Python program to print even numbers in a list
- Python program to print odd numbers in a List
- Python program to print positive numbers in a list
- Python program to print negative numbers in a list
- Python program to print all Strong numbers in given list
- Python | Merging duplicates to list of list
- Python | Convert list of numerical string to list of Integers
- Python | Remove Duplicates from a List
- Python | Remove consecutive duplicates from list
- Python | Ways to remove duplicates from list
- Python | Remove duplicates from nested list
- Python | Remove all duplicates and permutations in nested list
- Python | Sort given list by frequency and remove duplicates
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : sandeep_anand