We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 090ee0f commit 829376dCopy full SHA for 829376d
ReverseWordOrder.py
@@ -0,0 +1,16 @@
1
+# Write a program (using functions!) that asks the user for
2
+# a long string containing multiple words. Print back to the
3
+# user the same string, except with the words in backwards order.
4
+
5
+def string_mess(words):
6
+ #split string
7
+ wordlist = words.split(" ")
8
+ #reverse order
9
+ for i in range(int(len(wordlist)/2)):
10
+ word1 = wordlist[i]
11
+ wordlist[i] = wordlist[len(wordlist)-1-i]
12
+ wordlist[len(wordlist)-1-i] = word1
13
+ #rejoin string
14
+ return " ".join(wordlist)
15
16
+print(string_mess(input("What would you like to tell me?\n")))
0 commit comments