Method | Description |
---|---|
count() | To count the number of times a value appears in a tuple. |
index() | To find the index of any item. |
Python Tuple count()
Method
To count the number of times a value appears in a tuple.
In [1]:
emp_details = ('Tim','Smith','UK',28,True,'UK')
emp_details.count('UK')
Out[1]:
Python Tuple index()
Method
To find the index of any item.
In [1]:
emp_details = ('Tim','Smith','UK',28,True)
In [2]:
emp_details.index('Smith')
Out[2]:
It returns an error if the index is not found in the tuple.
In [3]:
emp_details.index('Tim5')