Chapters
Python114 chapters

ReferenceList methods

list.index()

The position of the first matching item.

Signature

items.index(value)

Parameters

NameMeans
valuewhat to look for

Returns

An int. Raises ValueError when there is no match.

Example

Python
names = ["Ada", "Grace", "Ada"]
print(names.index("Ada"))
print("Alan" in names)

Output

0
False

See also