Find what index an element is in a list
This question already has an answer here:
Of course there is. Try
>>> ['cow', 'dog', 'cat'].index('cow')
0
May i suggest, don't use list
as a variable name, as it is already used for constructing a list object.
上一篇: Python:列出.remove(item)但不是.find(item)或类似的东西?
下一篇: 查找元素在列表中的索引