Python‎ > ‎tuple‎ > ‎

tuple.index()

http://www.adilwaseem.com/

Introduction
Return first index of the item in tuple.

Syntax
tuple.index(x)->integer

Parameters
x=first index of the tuple item.

Example
The method returns with:
 tuple1=(44,22,22,22,45,555,32,33)
y=tuple1.index(555)
print("Return first index of the integer 22: ", y)
>>> 
return first index of the integer 22: 5
>>> 

index(str.rpartition())
The returns are following:
 >>> "Python Lake".rpartition("h")
('Pyt', 'h', 'on Lake')
>>> type("Python Lake".rpartition("h"))
<class 'tuple'>
>>> z="Python Lake".rpartition("h")
>>> z=('Pyt', 'h', 'on Lake')
>>> z=('Pyt', 'h', 'on Lake')
>>> z.index('h')
1
>>> 'Pyt'+'h'+ 'on Lake'
'Python Lake'
>>> z.count("Lake")
0
>>> z.count('h')
1

Comments