Write a Python Program to Find the length of a tuple. In this example, we declared integer and string tuples and used the len function to find those tuples’ lengths.
# Tuple Length
intTuple = (10, 20, 30, 40, 50)
print("Tuple Items = ", intTuple)
inttupleLength = len(intTuple)
print("Tuple Length = ", inttupleLength)
strTuple = ('apple', 'Mango', 'kiwi')
print("String Tuple Items = ", strTuple)
strtupleLength = len(strTuple)
print("String Tuple Length = ", strtupleLength)
Tuple Items = (10, 20, 30, 40, 50)
Tuple Length = 5
String Tuple Items = ('apple', 'Mango', 'kiwi')
String Tuple Length = 3
Python Program to Find the Length of a Tuple
In this example, we declared nested and mixed tuple. If you want the nested tuple length, you have to use that nested item’s index position. For instance, len(mTuple[4]) returns the length of a nested tuple (1, 2, 3, 4)
mTuple = ('Apple', 22, 'Kiwi', 45.6, (1, 2, 3, 4), 16, [10, 30, 70])
print("Mixed Tuple Items = ", mTuple)
mtupleLength = len(mTuple)
print("Mixed Tuple Length = ", mtupleLength)
nestedtupleLength = len(mTuple[4])
print("Nested Tuple Length = ", nestedtupleLength)
nestedlistLength = len(mTuple[6])
print("List Nested inside a Tuple Length = ", nestedlistLength)

In this Program, we declared an empty tuple and addicting the user given values to that tuple, and calculates the length.
# Tuple Length
intTuple = ()
number = int(input("Enter the Total Tuple Items = "))
for i in range(1, number + 1):
value = int(input("Enter the %d value = " %i))
intTuple += (value,)
print("Tuple Items = ", intTuple)
inttupleLength = len(intTuple)
print("Tuple Length = ", inttupleLength)
Enter the Total Tuple Items = 4
Enter the 1 value = 22
Enter the 2 value = 99
Enter the 3 value = 128
Enter the 4 value = 65
Tuple Items = (22, 99, 128, 65)
Tuple Length = 4