Python Tuple (tuple) len () method
description
Python tuple len () function calculates the number of elements in a tuple.
grammar
len () method syntax:
len(tuple1, tuple2)
parameter
- tuple - tuple to be calculated.
return value
Function returns the number of elements in a tuple.
Examples
The following example shows len () function to use:
#!/usr/bin/python tuple1, tuple2 = (123, 'xyz', 'zara'), (456, 'abc') print "First tuple length : ", len(tuple1); print "Second tuple length : ", len(tuple2);
Examples of the above output results are as follows:
First tuple length : 3 Second tuple length : 2