how to find the index of element in list in python code example

Example 1: get index of list python

list.index(element)

Example 2: how to get index in python

list.index(element, start, end)

Example 3: find an index of an item in a list python

#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])

Example 4: python search list of lists for value return index

[(i, colour.index(c))
 for i, colour in enumerate(colours)
 if c in colour]

Example 5: how to index python

#you can index in a string like:
string='cupcake'
string[0]#returns 'c'
#you can index in a list like:
list = ['red', 'blue', 'green']
list[0]#returns 'red'
list[0][0]#returns[0] of 'red' wich is r