About 5,070,000 results
Open links in new tab
  1. How to Find Duplicates in a ListPython | GeeksforGeeks

    Nov 27, 2024 · 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 …

  2. Identify duplicate values in a list in Python - Stack Overflow

    Is it possible to get which values are duplicates in a list using python? I have a list of items: mylist = [20, 30, 25, 20] I know the best way of removing the duplicates is set (mylist), but ...

  3. How To Find Duplicates In A Python List?

    Mar 4, 2025 · Learn how to find duplicates in a Python list using loops, `collections.Counter ()`, and `set ()`. This guide includes step-by-step examples for easy understanding.

  4. Program to print duplicates from a list of integers in Python

    Dec 27, 2024 · In this article, we will explore various methods to print duplicates from a list of integers in Python. The simplest way to do is by using a set. Set in Python only stores unique elements. So, we loop through the list and check if the current element already exist (duplicate) in the set, if true then keep this element to duplicate list.

  5. python - How do I find the duplicates in a list and create another list

    You basically remove duplicates by converting to set (clean_list), then iterate the raw_list, while removing each item in the clean list for occurrence in raw_list.

  6. Python - Duplicate Element Indices in List - GeeksforGeeks

    Feb 1, 2025 · We use list comprehension to create a dictionary where each duplicate element maps to a list of its indices filtering elements that appear more than once. This is achieved by iterating over unique elements and using enumerate () to collect indices of duplicates.

  7. 5 Best Ways to Find Duplicate Items in a List in Python

    Mar 3, 2024 · Problem Formulation: When working with lists in Python, a common task is to identify duplicate items. For example, given a list ['apple', 'banana', 'cherry', 'apple', 'cherry'], the goal is to detect the duplicates, yielding an output like ['apple', 'cherry']. This article explores various methods to find these duplicates efficiently.

  8. python - Efficiently finding duplicates in a list - Stack Overflow

    Oct 4, 2017 · for i in range(len(array)): for j in range(len(array)): comp1 = array[i] comp2 = array[j] if comp1 == comp2 and i!=j: if comp2 not in dupelist: dupelist.append(comp2) return dupelist. The idea here is to do a single sweep in linear time. You can use a counter to do this.

  9. Finding Duplicates in Python Lists - CodeRivers

    4 days ago · In Python programming, working with lists is a common task. One frequently encountered problem is identifying and handling duplicate elements within a list. Whether you are cleaning up data, validating user input, or performing data analysis, the ability to find duplicates in a list can be crucial. This blog post will dive deep into the fundamental concepts, various usage methods, common ...

  10. Python Find Duplicates in List - Know Program

    In Python, there are many methods available on the list data type that help you find duplicates elements from a given list. In this post, we are using set (), count (), list comprehension, enumerate (), slicing + in operator, and Brute Force approach.