Skip to content

Commit 8fa4161

Browse files
authored
docs: improve docstring clarity in reverse_words (#14212)
Updated function name and docstring for clarity.
1 parent ca5b8c1 commit 8fa4161

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

strings/reverse_words.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
def reverse_words(input_str: str) -> str:
2-
"""
3-
Reverses words in a given string
1+
def reverse_words(sentence: str) -> str:
2+
"""Reverse the order of words in a given string.
3+
4+
Extra whitespace between words is ignored.
5+
46
>>> reverse_words("I love Python")
57
'Python love I'
68
>>> reverse_words("I Love Python")
79
'Python Love I'
810
"""
9-
return " ".join(input_str.split()[::-1])
11+
return " ".join(sentence.split()[::-1])
1012

1113

1214
if __name__ == "__main__":

0 commit comments

Comments
 (0)