docs: improve docstring clarity in reverse_words (#14212)
Updated function name and docstring for clarity.
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
def reverse_words(input_str: str) -> str:
|
def reverse_words(sentence: str) -> str:
|
||||||
"""
|
"""Reverse the order of words in a given string.
|
||||||
Reverses words in a given string
|
|
||||||
|
Extra whitespace between words is ignored.
|
||||||
|
|
||||||
>>> reverse_words("I love Python")
|
>>> reverse_words("I love Python")
|
||||||
'Python love I'
|
'Python love I'
|
||||||
>>> reverse_words("I Love Python")
|
>>> reverse_words("I Love Python")
|
||||||
'Python Love I'
|
'Python Love I'
|
||||||
"""
|
"""
|
||||||
return " ".join(input_str.split()[::-1])
|
return " ".join(sentence.split()[::-1])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user