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
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…