ezoic

Wednesday, February 22, 2017

longest word

Write a function 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

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...