We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca5b8c1 commit 8fa4161Copy full SHA for 8fa4161
strings/reverse_words.py
@@ -1,12 +1,14 @@
1
-def reverse_words(input_str: str) -> str:
2
- """
3
- Reverses words in a given string
+def reverse_words(sentence: str) -> str:
+ """Reverse the order of words in a given string.
+
4
+ Extra whitespace between words is ignored.
5
6
>>> reverse_words("I love Python")
7
'Python love I'
8
>>> reverse_words("I Love Python")
9
'Python Love I'
10
"""
- return " ".join(input_str.split()[::-1])
11
+ return " ".join(sentence.split()[::-1])
12
13
14
if __name__ == "__main__":
0 commit comments