cf.VariableList.index

VariableList.index(value, start=0, stop=None)[source]

Return the first index of a given value.

Uses numerically tolerant equality where appropriate.

Parameters :
value :

The value to look for in the list.

start : int, optional

Start looking from this index. By default, look from the beginning of the list.

stop : int, optional

Stop looking before this index. By default, look up to the end of the list.

Returns :

out : int

Raises :
ValueError :

If the given value is not in the list.

Examples

>>> s
[1, 2, 3, 2, 4, 2]
>>> s.index(1)
1
>>> s.index(2, 2)
3
>>> s.index(2, start=2, stop=5)
3
>>> s.index(6)
ValueError: CfList doesn't contain: 6

Previous topic

cf.VariableList.hasprop

Next topic

cf.VariableList.insert

This Page