Python list index() method
Return the position of the first item equal to a value.
Syntax
list.index(value)
Raises ValueError if the value is missing.
Parameters
| value | what to find |
Return value
int
Example
Code
names = ["Sita", "Leo", "Mia"] print(names.index("Leo")) print("Raj" in names)
Output
1 False
Related
Learn it step by step in the free lesson Lists & Tuples, with exercises that check your answers.