You can use inbuilt method index() to get the index of an item in a list in Python as shown below –
1 2 3 4 5 |
mylist = ["cat","dog","tiger","rat","sheep"] print(mylist.index("dog")) ## Returns 1 print(mylist.index("rat")) ## Retursn 3 |