Length of a Python Tuple denotes the number of items in it.
To get the length of a Tuple in Python, use
len() builtin function. len() returns an integer representing the number of items in this Tuple.
Example 1: Length of Python Tuple
In this example, we have a Tuple with three items. When we use len() on the tuple, we should get 3 returned by the len() function.
tuple1 = ('Saranya', 'Surya', 'Sree', 'Ritha', 'Reshmi', 'Joy') #get tuple length tupleLength = len(tuple1) #print the value print(tupleLength)
Example 2: Length of Empty Tuple
Empty tuple contains no items, and therefore zero should be returned by len().
tuple1 = () tupleLength = len(tuple1) print(tupleLength)
In this Python Examples tutorial, we learned how to get the length of a Python Tuple.