dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68b7cadffed0e75a517da66f | Challenge 50: Longest Word | 29 | challenge-50 |
--description--
Given a sentence, return the longest word in the sentence.
- Ignore periods (
.) when determining word length. - If multiple words are ties for the longest, return the first one that occurs.
--hints--
get_longest_word("coding is fun") should return "coding".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_longest_word("coding is fun"), "coding")`)
}})
get_longest_word("Coding challenges are fun and educational.") should return "educational".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_longest_word("Coding challenges are fun and educational."), "educational")`)
}})
get_longest_word("This sentence has multiple long words.") should return "sentence".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_longest_word("This sentence has multiple long words."), "sentence")`)
}})
--seed--
--seed-contents--
def get_longest_word(sentence):
return sentence
--solutions--
def get_longest_word(sentence):
words = sentence.split()
longest = ''
for word in words:
clean_word = word.replace('.', '')
if len(clean_word) > len(longest):
longest = clean_word
return longest