Created
July 5, 2018 21:29
-
-
Save chausen/f486a421110b78ed95137d3eb805c61e to your computer and use it in GitHub Desktop.
Python Reverse Word Order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reverse_word_order(text): | |
newText = "" | |
position = 0 | |
for t in text: | |
if t == " ": | |
newText = text[position:text.find(t, position)] + " " + newText | |
position = text.find(t, position) + 1 | |
newText = text[position:] + " " + newText | |
return newText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment