Finding the Longest Word in Text

  • Share this:

Code introduction


Find the longest word in the given text.


Technology Stack : Python built-in libraries (str.split(), str.max(), len())

Code Type : String processing

Code Difficulty : Intermediate


                
                    
def get_longest_word(text):
    words = text.split()
    longest_word = max(words, key=len)
    return longest_word