-3

I want to find the index of an array like 3,4,7,8,11,12,14....using python

To find index,I am using below-

alist =[3,4,7,8]
x = int (input))
if x in alist:
    print alist.index(x)

The length of array is not fixed. How do I find index for nth value in array. Do I pass a variable to define array or something? Please help

user2332713
  • 21
  • 1
  • 9

2 Answers2

0

You can do Like this

print(alist.index(value))
0

you can use .index(value) method to use it

value_index = alist.index(value)
print(value_index )
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36