Is there a way to find index of "in" keyword match in python

ami*_*i91 1 python

The title of this post is probably pretty vague. Here is what I need to know

If I use something like

if x in list
Run Code Online (Sandbox Code Playgroud)

how do I find the index in the list where a match occurs?

Bre*_*arn 5

You can't get that from in itself. For lists, you can use the index method:

>>> [1, 2, 5, 8, -1, 2].index(2)
1
Run Code Online (Sandbox Code Playgroud)

This will raise an exception if the item is not in the list. Note that it returns the index of the first occurrence. It might occur multiple times.