find_longest_word()
that takes a list of words and returns the length of the longest one. Use only higher order functions.Solution:
class Solution:
def longest1(self, list1):
aa={}
for item in list1:
aa[item]=len(item)
max1=0
for key in aa.keys():
if aa[key]>max1:
max1=aa[key]
else:
max1=max1
lkey=list(aa.keys())[list(aa.values()).index(max1)]
return(lkey)
kk=Solution()
if __name__=="__main__":
print(kk.longest1(["atr","i","ertuo","worutynd"]))
hey it's Nick, how are you?
ReplyDelete