1# alphabets list
2alphabets = ['a', 'e', 'i', 'o', 'g', 'l', 'i', 'u']
3
4# index of 'i' in alphabets
5index = alphabets.index('i') # 2
6print('The index of i:', index)
7
8# 'i' after the 4th index is searched
9index = alphabets.index('i', 4) # 6
10print('The index of i:', index)
11
12# 'i' between 3rd and 5th index is searched
13index = alphabets.index('i', 3, 5) # Error!
14print('The index of i:', index)
1#Example List
2list = ['apples', 'bannas', 'grapes']
3#Use Known Entites In The List To Find The Index Of An Unknown Object
4Index_Number_For_Bannas = list.index('apples')
5#Print The Object
6print(list[Index_Number_For_Bannas])
7
1my_string = "Hello World!"
2
3my_string.index("l") # outputs 2
4# this method only outputs the index of the first "l" value in the string/list
1animals = ['cat', 'dog', 'rabbit', 'horse']
2
3# get the index of 'dog'
4index = animals.index('dog')
5
6
7print(index)
8
9# Output: 1