Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python len() function can be used to find out total number of elements in the tuple. To add more to this, len() function returns the number of elements in an iterable. An iterable object can be any data structure like list, tuple, set, string and dictionary, etc.

Syntax

len(tuple)

Parameters

tuple Required. specify iterable like a tuple to find out total number of elements in it.

Return Value

Returns the total number of elements in the tuple.

Example:

In the example below, len() function is used on the tuple called MyTuple to find out the total number of elements in it.

MyTuple = (10, 20, 30, 40, 50, 60)

print(len(MyTuple))

The output of the above code will be:

6

❮ Python Tuple Methods




5