给出一个词典,找出其中最长的单词
参考代码:
class Solution: def longesWords(self, dictionary): answer = [] maxLength = 0 for item in dictionary: if len(item) > maxLength: maxLength = len(item) answer = [item] elif len(item) == maxLength: answer.append(item) return answer