Use list.index(value) to find the position of the first matching element in a Python list. Positions start at zero. This tutorial explains optional search bounds, duplicate values, missing items and alternatives for finding every match.
Python list.index() syntax
items.index(value, start=0, stop=len(items))
value is the item to find. The optional start index is inclusive; stop is exclusive. Both bounds follow slice-style indexing, including negative positions. The result is always an index in the original list, not an offset from start. The actual method accepts positional arguments; the syntax above shows conceptual defaults.
Find the first matching item
names = ["John", "Adwin", "James", "Peter", "Annie", "Adwin"]
print(names.index("James")) # 2
print(names.index("Adwin")) # 1
The second occurrence of Adwin does not change the first-match result. List comparisons use equality (==), not necessarily object identity.
Search within a start and stop range
names = ["John", "Adwin", "James", "Peter", "Annie", "Adwin"]
print(names.index("Adwin", 2)) # 5
print(names.index("Peter", 1, 5)) # 3
print(names.index("Annie", -2)) # 4
The search interval is [start, stop): stop itself is excluded. A matching item outside the interval is not returned. Negative bounds are interpreted relative to the list length, just as in slicing.
Handle missing values without crashing
names = ["John", "Adwin", "James"]
try:
position = names.index("Kelly")
except ValueError:
position = None
print(position) # None
A missing value raises ValueError (not IndexError). Catch the exception when a miss is expected. If you only need to know whether an item exists, use "Kelly" in names. Checking membership and then calling index() scans the list twice in the worst case.
Find every matching index
names = ["John", "Adwin", "James", "Adwin"]
positions = [i for i, name in enumerate(names) if name == "Adwin"]
print(positions) # [1, 3]
list.index() returns one position only. Use enumerate() with a comprehension when you need every matching position.
Find tuples, dictionaries and nested lists
items = [(1, 2), {"a": "b"}, [True, False]]
print(items.index((1, 2))) # 0
print(items.index({"a": "b"})) # 1
print(items.index([True, False])) # 2
Nested structures are compared by value. Be aware that Python considers True == 1 to be true; if you need type-sensitive matching, check types explicitly.
Performance and common mistakes
list.index() performs a linear search: worst-case time is O(n), with O(1) additional space. Restricting the range can reduce the number of elements inspected, but it does not make list lookup indexed or logarithmic. Do not use the result as a one-based position. Do not expect -1 for missing values; Python raises ValueError.
Frequently asked questions
Does index() change the list? No. Can I use a negative start? Yes. Why is my result 0? The first list element has index 0. What if the value appears several times? Only the first match in the requested search range is returned.
Related reading: How to create a Python list and list.insert() explained. For the authoritative method specification, see the Python documentation on list methods.

C P Gupta is a YouTuber and Blogger. He is expert in Microsoft Word, Excel and PowerPoint. His YouTube channel @pickupbrain is very popular and has crossed 9.9 Million Views.
Very good blog article. Really looking forward to read more. Really Great!.
Welcome dear.
This is a great tip especially to those new to the blogosphere.
Short but very accurate information… Thanks for sharing this one.
A must read article!