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.
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 )
tup=[ (3, ), (1, 3), (6, 8), (4, 6, 8, 9), (2, 4) ]
max(map(len,tup))
result:
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With