Tuple in python
Tuple is immutable and we can't change the values.It takes less memory space and It is faster(Time).
Tuple methods
- count
- index
1. count()
"count()" function is used to return the number of count of the specified value in the tuple.
Syntax:
tuple.count(value)
Example-1
n = (10, 20, 30, 10) a = n.count(10) print(a)
Output
2
2. index()
"index()" function is used to find the index of the specified value in the tuple.
Syntax:
tuple.index(value)
Example-1
n = (10, 20, 30, 40) a = n.index(30) print(a)
Output
2