Daily Challenge #272

The Longest Word

Return the longest word in a sentence, keeping the first one when there is a tie.

◈ Graded Challenge

Write a function that returns the longest word in a sentence. If two words tie, return the one that appears first. Return an empty string for an empty sentence. Input: "go back and bring it forward" Output: "forward"

Name it exactly: def longest_word(sentence):

3 visible + 2 hidden
loading editor…

Where this fits

The daily challenge is practice, not a course. If you want the concepts behind it taught properly, the curriculum builds from your first web page through to a deployed full-stack application, and every course is free.

Explore the curriculumReference guides