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

    In Python 3, filter doesn't return a list, but a generator-like object. Finding the first occurrence If you only want the first thing that matches a condition (but you don't know what it is yet), it's …

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

    Here is another way using list comprehension (some people might find it debatable). It is very approachable for simple tests, e.g. comparisons on object attributes (which I need a lot): el = …

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

    This is the best one I have read. numpy arrays are far more efficient than Python lists. If the list is short it's no problem making a copy of it from a Python list, if it isn't then perhaps the …

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

    I've been Googling and searching the Python docs, and I think I might be able to do this with a list comprehension, but I'm not sure. I might add that I'm having to use Python 2.4.3 by the way, …

  5. Fastest way to search a list in python - Stack Overflow

    Sep 14, 2016 · When you do something like "test" in a where a is a list does python do a sequential search on the list or does it create a hash table representation to optimize the …

  6. python - Regular Expressions: Search in list - Stack Overflow

    Dec 20, 2024 · For Python 2.x developers, filter returns a list already. In Python 3.x filter was changed to return an iterator so it has to be converted to list (in order to see it printed out …

  7. Most efficient way for a lookup/search in a huge list (python)

    Dec 28, 2016 · If you don't want the memory overhead of a set then keep a sorted list and search through it with the bisect module. from bisect import bisect_left def bi_contains(lst, item): """ …

  8. python - Search in lists of lists by given index - Stack Overflow

    Here's the Pythonic way to do it: data = [['a','b'], ['a','c'], ['b','d']] search = 'c' any(e[1] == search for e in data)

  9. python - Using .find to search a string inside a list - Stack Overflow

    Jun 9, 2015 · Using a comprehension list, loop over the list and check if the string has the Hello! string inside, if yes, append the position to the matches list. Note: The enumerate build in …

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

    Search in python list of dict. 20. How to search through dictionaries? 0. list of dictionary search. 0 ...

Refresh