Account
Categories

Python Tuple Length (len())


Definition

It counts the total number of data items in a tuple. It is called the length of the tuple.

Now you will clearly understand the operation through the flowchart.

Tuple →  t = (10, 11, 12, 13)

Index :    0      1      2      3  
           ↓      ↓      ↓      ↓
Value :   10     11     12     13  

Counting →  10   11   12   13
            ↑     ↑    ↑    ↑
           (1)   (2)  (3)  (4)

Method →  len(t)

Total Items →  4

Syntax:

len(tuple_name)

Example:

t = (10, 11, 12, 13)

print(len(t))

Output:

Exercise

Create a tuple t = (5, 10, 15, 20) and find its length.