📜  遍历列表,查找特定数字和输出元素的索引 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:03.353000             🧑  作者: Mango

代码示例1
loop through list, find specific number and output element's index
numbers = [1,5,7,8,2,34,5,23,145,87]
N = 3
if N in numbers:
  print(numbers.index(N))
elif N not in numbers:
  print(-1)