de_front

Given a string, return a version without the first 2 chars. Except keep the first char if it is ‘a’ and keep the second char if it is ‘b’. The string may be any length. Harder than it looks.

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:

'Hello'

Output:

'llo'

Test 2

Input:

'java'

Output:

'va'

Test 3

Input:

'away'

Output:

'aay'

Test 4

Input:

'axy'

Output:

'ay'

Test 5

Input:

'abc'

Output:

'abc'

Test 6

Input:

'xby'

Output:

'by'

Test 7

Input:

'ab'

Output:

'ab'

Test 8

Input:

'ax'

Output:

'a'

Test 9

Input:

'axb'

Output:

'ab'

Test 10

Input:

'aaa'

Output:

'aa'

Test 11

Input:

'xbc'

Output:

'bc'

Test 12

Input:

'bbb'

Output:

'bb'

Test 13

Input:

'bazz'

Output:

'zz'

Test 14

Input:

'ba'

Output:

''

Test 15

Input:

'abxyz'

Output:

'abxyz'

Test 16

Input:

'hi'

Output:

''

Test 17

Input:

'his'

Output:

's'

Test 18

Input:

'xz'

Output:

''

Test 19

Input:

'zzz'

Output:

'z'