loop through list 2c find specific number and output element 27s index

Solutions on MaxInterview for loop through list 2c find specific number and output element 27s index by the best coders in the world

showing results for - "loop through list 2c find specific number and output element 27s index"
Ben
14 Sep 2019
1loop through list, find specific number and output element's index
2numbers = [1,5,7,8,2,34,5,23,145,87]
3N = 3
4if N in numbers:
5  print(numbers.index(N))
6elif N not in numbers:
7  print(-1)