start_oz

Given a string, return a string made of the first 2 chars (if present), however include first char only if it is ‘o’ and include the second only if it is ‘z’, so “ozymandias” yields “oz”.

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:

'ozymandias'

Output:

'oz'

Test 2

Input:

'bzoo'

Output:

'z'

Test 3

Input:

'oxx'

Output:

'o'

Test 4

Input:

'oz'

Output:

'oz'

Test 5

Input:

'ounce'

Output:

'o'

Test 6

Input:

'o'

Output:

'o'

Test 7

Input:

'abc'

Output:

''

Test 8

Input:

''

Output:

''

Test 9

Input:

'zoo'

Output:

''

Test 10

Input:

'aztec'

Output:

'z'

Test 11

Input:

'zzzz'

Output:

'z'

Test 12

Input:

'oznic'

Output:

'oz'