Phrase reversals
Phrase reversals is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Given a string of space separated words containing the following phrase:
- "rosetta code phrase reversal"
- Reverse the string.
- Reverse each individual word in the string, maintaining original string order.
- Reverse the order of each word of the phrase, maintaining the order of characters in each word.
Show your output here.
Python
<lang python>>>> phrase = "rosetta code phrase reversal" >>> phrase[::-1] # Reversed. 'lasrever esarhp edoc attesor' >>> ' '.join(word[::-1] for word in phrase.split()) # Words reversed. 'attesor edoc esarhp lasrever' >>> ' '.join(word for word in phrase.split()[::-1]) # Word order reversed. 'reversal phrase code rosetta' >>> </lang>