find_longest_word()
that takes a list of words and returns the length of the longest one.class Solution:
def longest1(self, l1):
len1=len(list(l1[0]))
for i in range(len(l1)):
if len(list(l1[i]))>len1:
len1=len(list(l1[i]))
else:
len1=len1
for i in range(len(l1)):
if len1==len(list(l1[i])):
return(len1,l1[i])
kk=Solution()
if __name__=='__main__':
print(kk.longest1(['aa','etryuiu','adf','erty',]))
No comments:
Post a Comment