← Back to Strings
Question 27
Swap The Halves
Swap The Halves
Read one word and print it with its two halves swapped: the second half first, then the first half. The split point half is already computed with floor division, so for an odd length the second half is the longer one. Input: one line, the word, no prompt. Build the new string from two slices, store it in swapped and print it on one line.
Expected Output:
honpyt= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
StringsSlicing
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.