user69090
0
Q:

find an index of an item in a list python

list.index(element)
13
test = [ 'test 1', 'test 2', 'test 3' ]
for index, value in enumerate( test ):
  print( index, value )
1
#Example List
list = ['apples', 'bannas', 'grapes']
#Use Known Entites In The List To Find The Index Of An Unknown Object
Index_Number_For_Bannas = list.index('apples')
#Print The Object
print(list[Index_Number_For_Bannas])
9
list.index(element, start, end)
3
[(i, colour.index(c))
 for i, colour in enumerate(colours)
 if c in colour]
0
First index of element "Ok" in the list :  1
0
list.index(element
0
# Find index position of first occurrence of 'Ok' in the list 
indexPos = listOfElems.index('Ok')
 
print('First index of element "Ok" in the list : ', indexPos)
0

New to Communities?

Join the community