With this operation, you can search for an item in an array based on its value. This method accepts only one argument, value. It is a non-destructive method, which means it does not affect the array values.

The syntax is

arrayName.index(value)

Example

Let’s find the value of “3” in the array. This method returns the index of the searched value.

import array as myarray
number = myarray.array('b', [2, 3, 4, 5, 6])              
print(number.index(3))