VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-find-duplicates-in-a-list-python/

⇱ How to Find Duplicates in a List - Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Find Duplicates in a List - Python

Last Updated : 23 Jul, 2025

Finding duplicates in a list is a common task in programming. In Python, there are several ways to do this. Let’s explore the efficient methods to find duplicates.

Using a Set (Most Efficient for Large Lists)

Set() method is used to set a track seen elements and helps to identify duplicates.


Output
[2, 3]

There are more approaches to Find Duplicates in a List :

Using collection.counter

Using collection.counter is efficient as in this Counter class from the collections module is greater for counting occurrences of each element .


Output
[2, 3]

Using List Comprehension

List comprehension allows us to write more compact code. We then use a list comprehension to find items that appear more than once and store them in the duplicates list. Here’s how we can find duplicates using list comprehension.


Output
[2, 3]
Comment