middle_two

Given a string of even length, return a string made of the middle two chars, so the string “string” yields “ri”. The string length will be at least 2.

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:

'string'

Output:

'ri'

Test 2

Input:

'code'

Output:

'od'

Test 3

Input:

'Practice'

Output:

'ct'

Test 4

Input:

'ab'

Output:

'ab'

Test 5

Input:

'0123456789'

Output:

'45'