back_around

Given a string, take the last char and return a new string with the last char added at the front and back, so “cat” yields “tcatt”. The original string will be length 1 or more.

This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.

Test 1

Input:

'cat'

Output:

'tcatt'

Test 2

Input:

'Hello'

Output:

'oHelloo'

Test 3

Input:

'a'

Output:

'aaa'

Test 4

Input:

'abc'

Output:

'cabcc'

Test 5

Input:

'read'

Output:

'dreadd'

Test 6

Input:

'boo'

Output:

'obooo'