- Mapping every word in the list to the length function and returning the max of them
- Then use the length of each word that matches the maximum word above
Code Example
def longestWordCheck(): words = ["hello", "world", "I", "am", "Longest", "Word"] maxWord = max(map(len, words)) for word in words: if len(word) == maxWord: print(word) if __name__ == "__main__": longestWordCheck()
OutPut
# Longest