middle_three

Given a string of odd length, return the string length 3 from its middle, so “Candy” yields “and”. The string length will be at least 3.

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:

'Candy'

Output:

'and'

Test 2

Input:

'and'

Output:

'and'

Test 3

Input:

'solving'

Output:

'lvi'

Test 4

Input:

'Hi yet Hi'

Output:

'yet'

Test 5

Input:

'java yet java'

Output:

'yet'

Test 6

Input:

'Chocolate'

Output:

'col'

Test 7

Input:

'XabcxyzabcX'

Output:

'xyz'