Python‎ > ‎operator‎ > ‎

operator.indexOf()

http://www.adilwaseem.com/

Introduction
The method returns with number are items before a in b.

Syntax
operator.indexOf(a,b)

Parameters
a=iterable
b=number

Import module
Importing module is required in the Shell window and the Editor window.

Examples
index(list, index number)
The method return items before the index number in list.
 >>> a=[5,6,2,1,55,3331]
>>> operator.indexOf(a,6)
1
>>> operator.indexOf(a,55)
4
>>> operator.indexOf(a,1)
3

index(string list, index number)
The method return the item before the index number in a list of string.
 >>> a=["Python", "Research", "Centre"]
>>> operator.indexOf(a,"Centre")
2
>>> operator.indexOf(a,"Python")
0

index(set, index number)
The method return result different then list unless the set is updated.
 >>> a={5,3,66,32,12}
>>> operator.indexOf(a,12)
3
>>> operator.indexOf(a,66)
1
>>> a.update()
>>> a
{32, 66, 3, 12, 5}
>>> a.update()
>>> a
{32, 66, 3, 12, 5}
>>> 

Comments