mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-18 03:37:35 +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'
|
'thousand'
|
||||||
>>> longest_word("To be or not to be that is the question")
|
>>> longest_word("To be or not to be that is the question")
|
||||||
'question'
|
'question'
|
||||||
>>> longest_word("All that glitters is not gold")
|
|
||||||
'glitters'
|
|
||||||
>>> longest_word("Beauty is in the eye of the beholder")
|
>>> longest_word("Beauty is in the eye of the beholder")
|
||||||
'beholder'
|
'beholder'
|
||||||
>>> longest_word("A picture is worth a thousand words")
|
>>> longest_word("A picture is worth a thousand words")
|
||||||
'thousand'
|
'thousand'
|
||||||
|
>>> longest_word("All that glitters is not gold")
|
||||||
|
'glitters'
|
||||||
"""
|
"""
|
||||||
words = sentence.split()
|
words = sentence.split()
|
||||||
return max(words, key=len) if words else ""
|
return max(words, key=len) if words else ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user