What is the more pythonic way of getting the length of the longest word:
len(max(words, key=len))
Or:
max(len(w) for w in words)>
I know it's been a year now but neverthless, I came up with this:
'''Write a function find_longest_word() that takes a list of words and returns the length of the longest one.'''
a = ['mamao', 'abacate', 'pera', 'goiaba', 'uva', 'abacaxi', 'laranja', 'maca']
def find_longest_word(a):
d = []
for c in a:
d.append(len(c))
e = max(d) #Try "min" :D
for b in a:
if len(b) == e:
print "Length is %i for %s" %(len(b), b)