Python计算索引位置

需要定义函数的方法,求出在列表中某个值的位置,需要有调用语句。怎么做呢,方法可以多一点!


def search_index(list, value):
    return list.index(value)


list_temp = [1, 2, 3, 4, 5]
value = 5
print(search_index(list_temp, value))

import numpy as np


def find_idx(List, e):
    return List.index(e)


def find_idx1(List, e):
    for i in range(len(List)):
        if List[i] == e:
            return i


def find_idx2(List, e):
    return np.where(np.array(List) == e)[0][0]