Get max length of multi-dimension tuple
python, tuples, variable-length
Solution
tup=[ (3, ), (1, 3), (6, 8), (4, 6, 8, 9), (2, 4) ]
max(map(len,tup))
result:
4
Problem
My tuple looks something like this(for a particular set of generated value) ``` tTrains = [ (3, ), (1, 3), (6, 8), (4, 6, 8, 9), (2, 4) ] ``` Now, what I need to find is the length of longest tuple inside this tuple/list. I can always use a for loop, iterate over all the sub-tuples and do it. But I want to ask if there's a predefined function for the same. Current Usage This is what I am going to use as of now ``` max = 0 for i in range( len(tTrains) ): if iMax < len( i ): iMax = len( i ) ```