front_back

Given a string, return a new string where the first and last chars have been exchanged.

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:

'code'

Output:

'eodc'

Test 2

Input:

'a'

Output:

'a'

Test 3

Input:

'ab'

Output:

'ba'

Test 4

Input:

'abc'

Output:

'cba'

Test 5

Input:

''

Output:

''

Test 6

Input:

'Chocolate'

Output:

'ehocolatC'

Test 7

Input:

'aavJ'

Output:

'Java'

Test 8

Input:

'hello'

Output:

'oellh'