Fetch any element through its index using index method
suggest changeindex()
returns first index of the matching value. Remember that arrays are zero-indexed.
my_array = array('i', [1,2,3,4,5])
print(my_array.index(5))
# 5
my_array = array('i', [1,2,3,3,5])
print(my_array.index(3))
# 3
Note in that second example that only one index was returned, even though the value exists twice in the array
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents