Skip to content

Instantly share code, notes, and snippets.

@chausen
Created July 5, 2018 21:29
Show Gist options
  • Save chausen/f486a421110b78ed95137d3eb805c61e to your computer and use it in GitHub Desktop.
Save chausen/f486a421110b78ed95137d3eb805c61e to your computer and use it in GitHub Desktop.
Python Reverse Word Order
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