Python OOPs


Python SQLite


Examples


Others


Python Tuple Methods


A tuple is a collection of objects which ordered and immutable. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuple is immutable unlike lists which are mutable. The tuples use parentheses, whereas lists use square brackets.

Method Description
count() Used to count the occurrence of a given value in a tuple
index() Used to return the index(position) of the given value.

count() Method
a=(1,2,3,4,5,6,3,0)
print(a.count(2))
Output
2

index() Method
a=(25,65,84,90,35)
print(a.index(90))
Output
3