curriculum/challenges/english/blocks/daily-coding-challenges-python/68b7cadffed0e75a517da66f.md
Given a sentence, return the longest word in the sentence.
.) when determining word length.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")`)
}})
def get_longest_word(sentence):
return sentence
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