Python Snippet PPP Q29

Raw Python Snippet (WIP)

# Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string:

#   My name is Michele
# Then I would see the string:

#   Michele is name My
# shown back to me.


def reverse_word(x):
  y = x.split()
  result = []
  for word in y:
    result.insert(0,word)
  return " ".join(result)


w = "My name is Michele"
print(reverse_word(w))