Have you thought about using Python list's .index(value) method? It return the index in the list of where the first instance of the value passed in is found.

Answer from Aaron on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ find-index-of-element-in-array-in-python
Find index of element in array in python - GeeksforGeeks
July 23, 2025 - We can use an index() method or a simple for loop to accomplish this task. index() method is the simplest way to find the index of an element in an array. It returns the index of the first occurrence of the element we are looking for.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ find-index-of-element-in-array-python
Find Index of Element in Array - Python - GeeksforGeeks
July 23, 2025 - It is simple to use and works well when we know the element exists in the array. It's efficient for arrays that do not have duplicate elements since it returns the first occurrence of the element. ... import array arr = array.array('i', [10, 20, 30, 40, 50]) # Find the index of the element 30 idx = arr.index(30) print(idx)
Discussions

efficiently finding the index of a value in a numpy array
You can use np.where(OPs_array==value) to get the indices. But if that is the main use of your array then consider using a dictionary. More on reddit.com
๐ŸŒ r/learnpython
1
3
September 9, 2022
How to find index of element? - Python - Data Science Dojo Discussions
Is it possible to find the index of the 100th element? I have created a random array using NumPyโ€™s function. Now, my target is to find the index of the 100th element of my array. Iโ€™m using the code below but it is showing an error. import numpy as np # create a 3-dimensional array of shape ... More on discuss.datasciencedojo.com
๐ŸŒ discuss.datasciencedojo.com
3
0
February 21, 2023
How to find index of value in NumPy array? - Data Exploration & Visualization - Data Science Dojo Discussions
Suppose I have an array that contains zero and non-zero values. Now I want to find the index of non-zero values of my array. I tried many methods previously, but they are not giving me the desired result. Can someone help me with this? More on discuss.datasciencedojo.com
๐ŸŒ discuss.datasciencedojo.com
3
0
February 17, 2023
Why no .get(idx[, default]) on python list??
There was a lengthy thread on this on Python-Ideas a couple of years ago: https://mail.python.org/archives/list/python-ideas@python.org/thread/LLK3EQ3QWNDB54SEBKJ4XEV4LXP5HVJS/ The clearest explanation of the most common objection was from Marc-Andre Lemburg: dict.get() was added since the lookup is expensive and you want to avoid having to do this twice in the common case where the element does exist. It was not added as a way to hide away an exception, but instead to bypass having to generate this exception in the first place. dict.setdefault() has a similar motivation. list.get() merely safes you a line of code (or perhaps a few more depending on how you format things), hiding away an exception in case the requested index does not exist. If that's all you want, you're better off writing a helper which hides the exception for you. I argue that making it explicit that you're expecting two (or more) different list lengths in your code results in more intuitive and maintainable code, rather than catching IndexErrors (regardless of whether you hide them in a method, a helper, or handle them directly). So this is more than just style, it's about clarity of intent. More on reddit.com
๐ŸŒ r/Python
94
144
June 23, 2022
๐ŸŒ
Python Guides
pythonguides.com โ€บ find-the-index-of-an-element-in-an-array-in-python
How To Find The Index Of An Element In An Array In Python?
March 19, 2025 - Learn how to find the index of an element in a Python array (or list) using methods like `index()`, loops, and NumPy's `where()`. Step-by-step examples included
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ efficiently finding the index of a value in a numpy array
r/learnpython on Reddit: efficiently finding the index of a value in a numpy array
September 9, 2022 -

I have a numpy array that has unique values and is static, and I routinely want to find some index of a value. Is it a good idea to repeatedly use where for this? Is numpy sorting the values and storing a mapping of them to the indices behind the scene, or otherwise doing something smart to quickly find the index? If not, what would be a good way to implement finding the index of a value in a numpy array?

๐ŸŒ
Pythonspot
pythonspot.com โ€บ array-find
Python Find In Array โ€” Tutorial with Examples | Pythonspot
January 1, 2026 - Array duplicates: If the array contains duplicates, the index() method will only return the first element. If you want multiple to find multiple occurrences of an element, use the lambda function below.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-find-the-index-of-value-in-numpy-array
How to find the Index of value in Numpy Array ? - GeeksforGeeks
July 23, 2025 - Create a NumPy array and iterate over the array to compare the element in the array with the given array. If the element matches print the index.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_search.asp
NumPy Searching Arrays
There is a method called searchsorted() which performs a binary search in the array, and returns the index where the specified value would be inserted to maintain the search order. The searchsorted() method is assumed to be used on sorted arrays. Find the indexes where the value 7 should be inserted:
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_indexing.asp
NumPy Array Indexing
To access elements from 2-D arrays we can use comma separated integers representing the dimension and the index of the element.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ find-element-in-array-python
Find element in Array - Python - GeeksforGeeks
July 23, 2025 - ... import array # Create an array ... print(f"Not found") ... If we want to find the index of an item in the array, we can use the index() method....
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ python
How to find index of element? - Python - Data Science Dojo Discussions
February 21, 2023 - Is it possible to find the index of the 100th element? I have created a random array using NumPyโ€™s function. Now, my target is to find the index of the 100th element of my array. Iโ€™m using the code below but it is showing an error. import numpy as np # create a 3-dimensional array of shape (10, 10, 10) arr = np.arange(1000).reshape((10, 10, 10)) indices = np.argpartition(arr.flatten(99)) index = np.unravel_index(indices[-1], arr.shape) print(index) TypeError Tr...
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python array index
Python Array Index - Spark By {Examples}
May 31, 2024 - Python Array index is commonly used to refer to the index of an element within an array. You can use array indexing to manipulate and access array
๐ŸŒ
datagy
datagy.io โ€บ home โ€บ python posts โ€บ python lists โ€บ python: find list index of all occurrences of an element
Python: Find List Index of All Occurrences of an Element โ€ข datagy
December 30, 2022 - NumPy makes the process of finding all index positions of an element in a list very easy and fast. This can be done by using the where() function. The where() function returns the index positions of all items in an array that match a given value.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-list-index
Python List index() Method Explained with Examples | DataCamp
March 28, 2025 - In this tutorial, you will learn about the Python index() function. The index() method searches an element in the list and returns its position/index. First, this tutorial will introduce you to lists, and then you will see some simple examples of how to work with the index() function.
๐ŸŒ
Flexiple
flexiple.com โ€บ python โ€บ find-index-of-element-in-list-python
Find index of element in list Python | Flexiple Tutorials | Python - Flexiple
March 10, 2022 - Discover how to find the index of an element in a list using Python. Our concise guide simplifies the process for efficient programming.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to find index of value in numpy array (with examples)
How to Find Index of Value in NumPy Array (With Examples)
September 17, 2021 - This tutorial explains how to find the index location of specific values in a NumPy array, including examples.
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-find-index-of-item-in-list
How to find index of an item in a list?
To find the index of a specific element in a given list in Python, you can call the list.index() method on the list object and pass the specific element as argument.
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ data exploration & visualization
How to find index of value in NumPy array? - Data Exploration & Visualization - Data Science Dojo Discussions
February 17, 2023 - Suppose I have an array that contains zero and non-zero values. Now I want to find the index of non-zero values of my array. I tried many methods previously, but they are not giving me the desired result. Can someone helโ€ฆ