Python Tuple Length

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.

Python Program

tuple1 = ('Saranya', 'Surya', 'Sree', 'Ritha', 'Reshmi', 'Joy')
#get tuple length
tupleLength = len(tuple1)
#print the value
print(tupleLength)
Run

Output

6

Example 2: Length of Empty Tuple

Empty tuple contains no items, and therefore zero should be returned by len().

Python Program

tuple1 = ()

tupleLength = len(tuple1)

print(tupleLength)
Run

Output

0

Summary

In this Python Examples tutorial, we learned how to get the length of a Python Tuple.