Part 1: Reverse a string (abc -> cba). Part 2: Reverse the words in a string (practice makes perfect -> perfect makes practice). Part 3: Reverse words in a string, but keep non-alphanumeric character placement (I'm great, thanks! -> Thanks I'm, great!). Asked in the phone interview stage. Apostrophe counts as alphanumeric.
Write a function that handles all three parts. For part 3, treat apostrophes as part of a word, and keep punctuation attached to the same relative word boundary after reversing the word order.
def reverse_text(s, part):
s is a stringpart is 1, 2, or 3def reverse_text(s, part):