For lists, the method list.index(x)
returns the index in the list of the first item whose value is x
. But if I want to look inside the list items, and not just at the whole items, how do I make the most Pythoninc method for this?
For example, with
l = ['the cat ate the mouse','the tiger ate the chicken','the horse ate the straw']
this function would return 1
provided with the argument tiger
.