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 9b376a5 commit 20c2db0Copy full SHA for 20c2db0
1 file changed
strings/reverse_words.py
@@ -1,4 +1,5 @@
1
# Created by sarathkaul on 18/11/19
2
+# Edited by farnswj1 on 4/4/20
3
4
5
def reverse_words(input_str: str) -> str:
@@ -13,10 +14,7 @@ def reverse_words(input_str: str) -> str:
13
14
input_str = input_str.split(" ")
15
new_str = list()
16
- for a_word in input_str:
17
- new_str.insert(0, a_word)
18
-
19
- return " ".join(new_str)
+ return ' '.join(reversed(input_str))
20
21
22
if __name__ == "__main__":
0 commit comments