Python tuple method len() returns the number of elements in the tuple.
Following is the syntax for len() method −
len(tuple)
This method returns the number of elements in the tuple.
The following example shows the usage of len() method.
#!/usr/bin/python tuple1, tuple2 = (123, 'xyz', 'zara'), (456, 'abc') print "First tuple length : ", len(tuple1) print "Second tuple length : ", len(tuple2)
When we run above program, it produces following result −
First tuple length : 3 Second tuple length : 2