About 206,000 results
Open links in new tab
  1. python - Find a value in a list - Stack Overflow

    EDIT FOR REOPENING: the question has been considered duplicate, but I'm not entirely convinced: here this question is roughly "what is the most Pythonic way to find an element in a …

  2. python - How can I find the index for a given item in a list? - Stack ...

    Caveats Linear time-complexity in list length An index call checks every element of the list in order, until it finds a match. If the list is long, and if there is no guarantee that the value will be …

  3. Python: finding an element in a list - Stack Overflow

    What is a good way to find the index of an element in a list in Python? Note that the list may not be sorted. Is there a way to specify what comparison operator to use?

  4. python - How to find all occurrences of an element in a list - Stack ...

    index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?

  5. Searching a list of objects in Python - Stack Overflow

    Let's assume I'm creating a simple class to work similar to a C-style struct, to just hold data elements. I'm trying to figure out how to search a list of objects for objects with an attribute equ...

  6. Search a list of dictionaries in Python - Stack Overflow

    Unless somewhere else you keep a dictionary of the names pointing to the items of the list, but then you have to take care of the consequences of popping an element from your list.

  7. python - How do I get the last element of a list? - Stack Overflow

    Jun 14, 2019 · Downvoted because I feel the core of this answer is incorrect. Getting a list when you want an element only postpones the inevitable "list index out of range" - and that's what …

  8. How do I count the occurrences of a list item? - Stack Overflow

    Apr 8, 2010 · 2219 Given a single item, how do I count occurrences of it in a list, in Python? A related but different problem is counting occurrences of each different element in a collection, …

  9. python - Find elements in one list that are not in the other - Stack ...

    Are you looking for elements in list_2 that appear nowhere in list_1 or elements in list_2 that are not present at the same index in list_1?

  10. python - Find the greatest (largest, maximum) number in a list of ...

    Mar 8, 2023 · 0 Same question was asked to me in interview, What are the ways, to find maximum number out of four numbers input by different user in python. So i explained and …