18 August 2026
Longest Word
Easy
Strings
Find the single longest word in a sentence.
Given a sentence of lowercase words separated by single spaces, return the longest word. If more than one word shares the longest length, return whichever of them appears first in the sentence.
Constraints
1 <= number of words <= 1000Each word contains only lowercase English letters1 <= length of each word <= 100
Function signature
def longest_word(sentence):