at_first

Given a string, return a string length 2 made of its first 2 chars. If the string length is less than 2, use ‘@’ for the missing chars.

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:

'he'

Test 2

Input:

'hi'

Output:

'hi'

Test 3

Input:

'h'

Output:

'h@'

Test 4

Input:

''

Output:

'@@'

Test 5

Input:

'kitten'

Output:

'ki'

Test 6

Input:

'java'

Output:

'ja'

Test 7

Input:

'j'

Output:

'j@'