About 516,000 results
Open links in new tab
  1. Best way to handle list.index (might-not-exist) in python?

    Of course the question asks specifically about lists so the best solution is to use the try-except method, however the speed improvements (at least 20x here compared to try-except) offered …

  2. list.index () function for Python that doesn't throw exception when ...

    Python's list.index(x) throws an exception if the item doesn't exist. Is there a better way to do this that doesn't require handling exceptions?

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

    The returned index is computed relative to the beginning of the full sequence rather than the start argument. Caveats Linear time-complexity in list length An index call checks every element of …

  4. Using Python's list index() method on a list of tuples or objects?

    74 Python's list type has an index () method that takes one parameter and returns the index of the first item in the list matching the parameter. For instance:

  5. Complexity of list.index (x) in Python - Stack Overflow

    Nov 18, 2021 · The "Index" that your link is talking about is the same as Get Item in the python.org wiki. You can see in the cpython source code that the index method is doing an O …

  6. python - Why doesn't list have safe "get" method like dictionary ...

    172 Ultimately it probably doesn't have a safe .get method because a dict is an associative collection (values are associated with names) where it is inefficient to check if a key is present …

  7. Difference between del, remove, and pop on lists in Python

    Related post on similar lines for set data structure - Runtime difference between set.discard and set.remove methods in Python?

  8. Finding first and last index of some value in a list in Python

    Feb 7, 2009 · Is there any built-in methods that are part of lists that would give me the first and last index of some value, like: verts.IndexOf(12.345) verts.LastIndexOf(12.345)

  9. python - Insert an element at a specific index in a list and return …

    Here's the timeit comparison of all the answers with list of 1000 elements on Python 3.9.1 and Python 2.7.16. Answers are listed in the order of performance for both the Python versions.

  10. Finding the index of elements based on a condition using python …

    "In Python, you wouldn't use indexes for this at all, but just deal with the values" this statement shows you haven't done enough data analysis and machine learning modeling. Indices of one …