About 7,280,000 results
Open links in new tab
  1. python - How can I find same values in a list and group together …

    What you want to do is: for each value, if it's the same as the last value, just append it to the list of last values; otherwise, create a new list. You can translate that English directly to Python: …

  2. python - Indexing of Same Values in a List - Stack Overflow

    Jun 22, 2020 · Due to list.index(x) will only return the index in the list of the first item whose value is x. Is there any way to return every index of same values in the list. For example, I have a list …

  3. Python: Find identical items in multiple lists - Stack Overflow

    Jan 9, 2017 · I've updated the answer to clarify that it only finds the intersection. Cleanest way would probably be to use reduce: def R(a, b, seen=set()): a.update(b & seen) seen.update(b) …

  4. Python – Check if all elements in List are same - GeeksforGeeks

    Dec 10, 2024 · Using set () is the best method to check if all items are same in list. Explanation: Converting given list to set will take O (n) time, because we are adding each item in set. In …

  5. Find Index of Same Element in Python List | Get Repeated Item

    How to get the index of same element in list in the Python programming language - Get index of same element in list using for loop

  6. Check if two lists are identical in Python - GeeksforGeeks

    May 3, 2025 · Our task is to check if two lists are identical or not. By “identical”, we mean that the lists contain the same elements in the same order. The simplest way to check if two lists are …

  7. Python Check if List Contains Same Elements - Know Program

    In Python, there are many methods available on the list data type that help you check the same element or not. In this post, we are using native method, set (), len (), all (), count (), groupby …

  8. 5 Best Ways to Check for Same Value and Frequency of Elements in Python

    Mar 3, 2024 · For instance, given two lists [1,2,3,4] and [2,3,4,2], the program should check if there are elements with matching values and frequencies (in this case, no). Method 1: Using a …

  9. Check If All Elements in a List Are Same in Python

    Learn how to check if all elements in a list are the same using Python with simple examples and explanations.

  10. Determine if Two Lists Have Same Elements, Regardless of Order

    Mar 31, 2023 · There are two main methods to determine whether two Python lists contain the same elements in any order: sorting and comparing or using sets. Sorting and comparing work …

  11. Some results have been removed
Refresh