mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-31 10:56:43 +00:00
Update longest_word_in_sentence.py
This commit is contained in:
parent
b908d84c0f
commit
84628de8dc
@ -13,12 +13,12 @@ def longest_word(sentence: str) -> str:
|
||||
'thousand'
|
||||
>>> longest_word("To be or not to be that is the question")
|
||||
'question'
|
||||
>>> longest_word("All that glitters is not gold")
|
||||
'glitters'
|
||||
>>> longest_word("Beauty is in the eye of the beholder")
|
||||
'beholder'
|
||||
>>> longest_word("A picture is worth a thousand words")
|
||||
'thousand'
|
||||
>>> longest_word("All that glitters is not gold")
|
||||
'glitters'
|
||||
"""
|
||||
words = sentence.split()
|
||||
return max(words, key=len) if words else ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user